2K نرخ ANR را تا 35 درصد با کیت توسعه بازی اندروید کاهش می دهد
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
پس زمینه

Cat Daddy Games یک استودیوی کاملاً متعلق به 2K است که در کرکلند، واشنگتن و توسعهدهنده NBA 2K Mobile است. این تیم میخواست کیفیت و ثبات کلی بازیهای خود را بهبود بخشد، بهویژه با کاهش خطاهای «برنامه پاسخ نمیدهد» (ANR). ANR زمانی رخ میدهد که رشته رابط کاربری یک برنامه Android برای مدت طولانی مسدود شود. وقتی این اتفاق میافتد، رشته اصلی برنامه که مسئول بهروزرسانی رابط کاربری است، نمیتواند رویدادهای ورودی کاربر را ترسیم یا پردازش کند و باعث ناامیدی کاربر میشود. اگر برنامه در پیش زمینه در حال اجرا باشد، سیستم گفتگویی را نمایش می دهد که به کاربر اجازه می دهد برنامه را به اجبار ترک کند.
کاری که آنها انجام دادند
کاهش ANR برای Cat Daddy اولویت بالایی داشته است. تیم QA بی وقفه کار کرد و یک الگوی رایج ANR را مشخص کرد: آنها متوجه شدند که وقتی برنامه متوقف می شود و سپس به سرعت از سر گرفته می شود، مقدار زیادی از ورودی لمسی می تواند باعث ANR شود. بررسی بیشتر با Firebase Crashlytics نشان داد که این ANR از نوع android.os.MessageQueue.nativePollOnce، رایج ترین نوع ANR برای NBA 2K Mobile بود.
Cat Daddy همچنین دید که مدیریت ورودی بهبود یافته در GameActivity می تواند از این نوع ANR جلوگیری کند، بنابراین آنها تصمیم گرفتند به GameActivity بروند.
GameActivity جزئی از کیت توسعه بازی اندروید است که برای کمک به بازی های اندروید در پردازش دستورات چرخه برنامه، رویدادهای ورودی و ورودی متن در کد C/C++ برنامه طراحی شده است. GameActivity چندین پیشرفت مبتنی بر بازی را نسبت به NativeActivity
ارائه می دهد، مانند Fragment
، رندر کردن به SurfaceView
، و سایر پشتیبانی ها برای کتابخانه های مرتبط با توسعه بازی محبوب.
GameActivity همچنین از بافر مضاعف در بافر ورودی خود استفاده می کند، که به بازی اجازه می دهد تا با حجم ورودی بالا بهتر مدیریت کند.
نتایج
با اجرای GameActivity، Cat Daddy توانست به طور قابل توجهی مدیریت ورودی بازی را بهبود بخشد و منجر به کاهش 35 درصدی خطاهای ANR شود. این باعث بهبود تجربه کاربر و ایجاد یک تجربه گیم پلی پایدارتر شد.
به عنوان یک امتیاز اضافی، چون GameActivity از FragmentActivity
به ارث میرسد، CatDaddy همچنین توانست EmbeddedWebView و EmbeddedVideoView را که برای برخی از محبوبترین ادغامهای بازیهای اجتماعی مورد نیاز بودند، ادغام کند.
شروع کنید
تجربه بازی خود را با GameActivity و بقیه کیت توسعه بازی اندروید بهبود بخشید.
محتوا و نمونه کدها در این صفحه مشمول پروانههای توصیفشده در پروانه محتوا هستند. جاوا و OpenJDK علامتهای تجاری یا علامتهای تجاری ثبتشده Oracle و/یا وابستههای آن هستند.
تاریخ آخرین بهروزرسانی 2022-12-09 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2022-12-09 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# 2K reduces ANR rate by 35% with the Android Game Development Kit\n\nBackground\n----------\n\nCat Daddy Games is a wholly-owned\n[2K](https://play.google.com/store/apps/dev?id=6681606924556273560)\nstudio based in Kirkland, Washington and the developer of NBA 2K Mobile.\nThe team wanted to improve the overall quality and stability of their games,\nspecifically by reducing \"Application Not Responding\" errors (ANRs). ANRs\noccur when the UI thread of an Android app is blocked for too long. When\nthat happens, the app's main thread, which is responsible for updating the\nUI, can't draw or process user input events, causing frustration to the user.\nIf the app is running in the foreground, the system displays a dialog that\nallows the user to force-quit the app.\n\nWhat they did\n-------------\n\nReducing ANRs has been a high priority for Cat Daddy. The QA team worked\nrelentlessly and nailed down a common ANR pattern: they found that when the app\nwas paused and then quickly resumed, a large amount of touch input could cause\nan ANR. Further investigation with\n[Firebase Crashlytics](https://firebase.google.com/docs/crashlytics) showed\nthat this ANR was of type android.os.MessageQueue.nativePollOnce, the most\ncommon type of ANR for NBA 2K Mobile.\n\nCat Daddy also saw that the improved input handling in GameActivity could avoid\nthis type of ANRs, so they decided to move to GameActivity.\n\n[GameActivity](/games/agdk/game-activity) is a component of the\n[Android Game Development Kit](/stories/games/games/agdk), which\nis designed to assist Android games in processing app cycle commands, input\nevents, and text input in the application's C/C++ code. GameActivity offers a\nnumber of game-focused improvements over `NativeActivity`, such as\n[`Fragment`](/reference/androidx/fragment/app/Fragment), rendering to a\n[`SurfaceView`](/reference/android/view/SurfaceView), and other support\nfor popular game development-related libraries.\n\nGameActivity also uses double buffering in its input buffer, allowing the game\nto better handle this case of high input volume.\n\nResults\n-------\n\nBy implementing GameActivity, Cat Daddy was able to significantly improve the\ninput handling of the game, leading to a 35% reduction in ANR errors. This\nimproved the user experience and created a more stable gameplay experience.\n\nAs an added bonus, because GameActivity inherits from\n[`FragmentActivity`](/reference/androidx/fragment/app/FragmentActivity),\nCatDaddy was also able to integrate EmbeddedWebView and EmbeddedVideoView,\nwhich were required for some of the most popular social game integrations.\n\nGet started\n-----------\n\nImprove your own game experience with [GameActivity](/games/agdk/game-activity)\nand the rest of the [Android Game Development Kit](/games/agdk)."]]