2K は Android Game Development Kit を使用して ANR 発生率を 35% 削減
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
背景

Cat Daddy Games は、ワシントン州カークランドに拠点を置く 2K 完全所有のスタジオで、NBA 2K Mobile のデベロッパーです。チームは、特に「アプリケーション応答なし」エラー(ANR)を減らすことで、ゲームの全体的な品質と安定性を改善する必要がありました。ANR は、Android アプリの UI スレッドが長時間ブロックされると発生します。そのような場合、UI を更新する役割を担うアプリのメインスレッドがユーザー入力イベントを描画または処理できなくなり、ユーザーに不満を抱かせることになります。アプリがフォアグラウンドで実行されている場合は、ユーザーがアプリを強制終了できるダイアログが表示されます。
Eyecon の取り組み
ANR の削減は、Cat Daddy にとって最優先事項でした。QA チームは粘り強く取り組み、一般的な ANR パターンを突き止めました。そこで、アプリが一時停止してからすぐに再開すると、大量のタップ入力で ANR が発生する可能性があることがわかりました。Firebase Crashlytics でさらに調査を行った結果、この ANR のタイプは android.os.MessageQueue.nativePollOnce であり、NBA 2K Mobile の ANR の最も一般的なタイプであることがわかりました。
また、GameActivity の入力処理を改善することでこの種の ANR を回避できるとわかったため、Cat Daddy は GameActivity に移行することにしました。
GameActivity は Android Game Development Kit のコンポーネントで、Android ゲームがアプリの C/C++ コードでアプリサイクル コマンド、入力イベント、テキスト入力を処理する際に設計されています。GameActivity は、Fragment
や SurfaceView
へのレンダリング、一般的なゲーム開発関連ライブラリのその他のサポートなど、NativeActivity
と比べてゲームに焦点を当てたさまざまな改善を提供します。
また、GameActivity は入力バッファでダブル バッファリングを使用して、この入力量が多い場合のゲームの処理を改善します。
結果
Cat Daddy は GameActivity を実装することで、ゲームの入力処理を大幅に改善し、ANR エラーを 35% 削減できました。これにより、ユーザー エクスペリエンスが向上し、より安定したゲームプレイ エクスペリエンスが実現しました。
また、GameActivity は FragmentActivity
を継承するため、CatDaddy は、人気のソーシャル ゲーム統合で必要だった EmbedWebView と EmbeddedVideoView も統合できました。
始める
GameActivity や Android Game Development Kit の他の機能を利用して、ゲーム エクスペリエンスを改善できます。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2022-12-09 UTC。
[null,null,["最終更新日 2022-12-09 UTC。"],[],[],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)."]]