شركة 2K تقلّل نسبة أحداث ANR بنسبة% 35 باستخدام مجموعة أدوات Android Game Development Kit
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
خلفية

Cat Daddy Games هي استوديو
2K مملوك بالكامل ومقيم في كيركلاند بواشنطن، وهي شركة مطوّرة لـ NBA 2K Mobile.
أراد الفريق تحسين الجودة والثبات بشكل عام في ألعابهم، وتحديدًا من خلال تقليل أخطاء "التطبيق لا يستجيب" (ANR). تحدث أخطاء ANR عندما يتم حظر مؤشر ترابط واجهة المستخدم
لتطبيق Android لفترة طويلة جدًا. عندما يحدث ذلك، فإن سلسلة التعليمات الرئيسية للتطبيق، وهي المسئولة عن تحديث واجهة المستخدم، لا يمكنها رسم أو معالجة أحداث إدخال المستخدم، مما يتسبب في شعور المستخدم بالإحباط.
إذا كان التطبيق قيد التشغيل في المقدّمة، يعرض النظام مربّع حوار
يسمح للمستخدم بفرض إنهاء التطبيق.
الإجراءات التي اتخذتها الشركة
يمثّل تقليل أخطاء ANR أولوية قصوى لدى Cat Daddy. عمل فريق ضمان الجودة بلا جدوى وتوصل إلى نمط شائع لخطأ ANR: حيث وجدوا أنه عندما يتم إيقاف التطبيق مؤقتًا ثم تم استئنافه بسرعة، يمكن أن يتسبب قدر كبير من الإدخال باللمس في حدوث خطأ ANR. وقد أظهر مزيد من التحقيقات التي تم إجراؤها باستخدام
Firebase Crashlytics أنّ
خطأ ANR هذا كان من النوع android.os.MessageQueue.authorizedPoll البيانية، وهو النوع الأكثر
شيوعًا من أخطاء ANR في NBA 2K Mobile.
رأت Cat Daddy أيضًا أن المعالجة المحسّنة للإدخالات في GameActivity يمكن أن تتجنب
هذا النوع من أخطاء ANR، لذا قررت الانتقال إلى GameActivity.
إنّ GameActivity هو أحد مكونات
مجموعة أدوات تطوير ألعاب Android التي صُممت لمساعدة ألعاب Android في معالجة أوامر دورة التطبيقات وأحداث الإدخال وإدخال النص في رمز C/C++ للتطبيق. تقدّم GameActivity
عددًا من التحسينات التي تركّز على الألعاب على الإصدار NativeActivity
، مثل
Fragment
وعرض
SurfaceView
وغير ذلك من أشكال الدعم
للمكتبات الرائجة ذات الصلة بتطوير الألعاب.
تستخدم GameActivity أيضًا ميزة التخزين المؤقت المزدوج في المخزن المؤقت للإدخال، ما يسمح للّعبة بالتعامل بشكل أفضل مع هذه الحالة ذات حجم الإدخال العالي.
النتائج
من خلال تنفيذ GameActivity، تمكّنت Cat Daddy بشكل كبير من تحسين طريقة معالجة الإدخالات في اللعبة، ما أدّى إلى تقليل أخطاء ANR بنسبة% 35. أدى ذلك إلى تحسين تجربة المستخدم وخلق تجربة لعب أكثر ثباتًا.
وكمكافأة إضافية، نظرًا إلى أنّ GameActivity تكتسِب من
FragmentActivity
،
تمكّنت CatDaddy أيضًا من دمج builtWebView وBrowserVideoView
اللذين كانا مطلوبَين لبعض عمليات دمج الألعاب على الشبكات الاجتماعية الأكثر رواجًا.
البدء
يمكنك تحسين تجربة لعبتك من خلال GameActivity
وباقي حزمة تطوير ألعاب Android.
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java و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)."]]