[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-02-06 (世界標準時間)。"],[],[],null,["# Mir 2 improves rendering performance by using the Frame Pacing library\n\nMir 2: Return of the King\n\n[Mir 2: Return of the King](https://play.google.com/store/apps/details?id=com.krsc.shark) is a high-quality Legend IP mobile\ngame authorized by Actoz Soft and developed by\n[HK ZHILI YAOAN LIMITED](https://www.zhiliyaoan.com/) using the Unity game engine.\n\nThis game not only perfectly recreates the feelings of *Mir 2*, a\nrepresentative of Korean fantasy MMORPG, but also offers many of the most\npopular game contents, such as equipment collection, large-scale sand attack,\nand other core gameplay.\n\nThe game used the Android [Frame Pacing library](/games/sdk/frame-pacing) (Swappy) to improve the\nstability of its frame rate, achieve smooth rendering, and significantly boost\ntheir Android Vitals (Slow Session metric).\n\n**Slow Sessions launched on Android vitals**\n--------------------------------------------\n\n[Slow Sessions](/topic/performance/vitals/slow-session) is an Android vitals metric in Google Play console. A slow\nsession has more than 25% slow frames. A frame is slow if it is:\n\n1. At 20fps, it is not presented within 50ms after the previous frame.\n\n2. At 30fps, it is not presented within 34ms after the previous frame.\n\nIn due course, Play will start steering users away from games that cannot\nachieve 20 FPS on their phones.\n\nThere are many reasons a frame might present or render longer on the screen than\nthe developer's target frame time. The game could be CPU or GPU bound,\noverheating (causing thermal throttling), or there's a **mismatch in the game's\nframerate and the device's display refresh rate**.\n\n**What is the Frame Pacing library**\n------------------------------------\n\nThe Android [Frame Pacing library](/games/sdk/frame-pacing), also known as Swappy, is part of the AGDK\nlibraries. Swappy helps OpenGL and Vulkan games achieve smooth rendering and\ncorrect frame pacing on Android.\n\nThe library handles multiple refresh rates if they are supported by the device,\nwhich gives a game more flexibility in presenting a frame. For example, for a\ndevice that supports a 60 Hz refresh rate as well as 90 Hz, a game that cannot\nproduce 60 frames per second can drop to 45 FPS instead of 30 FPS to remain\nsmooth. The library detects the expected game frame rate and auto-adjusts frame\npresentation times accordingly.\n\nThe Frame Pacing library also improves battery life because it avoids\nunnecessary display updates. For example, if a game is rendering at 60 FPS but\nthe display is updating at 120 Hz, the screen is updated twice for every frame.\nThe Frame Pacing library avoids this by setting the refresh rate to the value\nsupported by the device that's closest to the target frame rate.\n\nHow Mir 2 improved Rendering performance with the Frame Pacing library\n----------------------------------------------------------------------\n\nMir 2 ([미르2: 왕의 귀환](https://play.google.com/store/apps/details?id=com.krsc.shark)) was facing an issue with unstable\nrendering performance where they experienced 40% slow sessions at a framerate\nthreshold of 20 FPS, much higher than Google Play's 20% threshold.\n**Figure 1.** Slow session metric before integrating the Frame Pacing library.\n\nMir 2 ([미르2: 왕의 귀환](https://play.google.com/store/apps/details?id=com.krsc.shark)) is a high fidelity graphic game, some\ndevices are facing challenges to maintain a stable FPS. Their\n[frame rate distribution](https://support.google.com/googleplay/android-developer/answer/9844486#zippy=%2Cslow-session-rate-fps-or-fps-games-only) shows lots of sessions are running at\nFPS lower than 20fps.\n**Figure 2.** The game's FPS distribution before integrating the Frame Pacing library. \nEach bucket represents the percentage of sessions where 75% of their frames were faster than the bucket label.\n\nWhen the display workload takes longer than the application workload,\nadditional frames are added to a queue. This leads, once again, to stuttering\nand may also lead to an extra frame of latency due to buffer-stuffing.\n**Figure 3.** Long frame B gives incorrect pacing for 2 frames---A and B.\n\nThe Frame Pacing library solves this by using sync fences\n([`EGL_KHR_fence_sync`](https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt) and [`VkFence`](https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkFence.html)) to\ninject waits into the application that allow the display pipeline to catch up,\nrather than allowing back pressure to build up. Frame A still presents an extra\nframe, but frame B now presents correctly.\n**Figure 4.** Frames C and D wait to present.\n\nMir 2 easily integrated the Frame Pacing library by leveraging Unity's built in\n[Optimized Frame Pacing](https://docs.unity3d.com/Manual/class-PlayerSettingsAndroid.html) feature. The action resulted in\nsignificant improvement for their rendering performance, specifically dropping\nthe Slow Session metric from **40%** to **10%**.\n**Figure 5.** Slow Session improvement after integrating the Frame Pacing library.\n\nThe number of slow sessions have been reduced significantly for Mir2 after they\nintegrated the library.\n**Figure 6.** The game's FPS distribution after integrating frame pacing. \nEach bucket represents the percentage of sessions where 75% of their frames were faster than the bucket label.\n\nGet Started with the Frame Pacing library\n-----------------------------------------\n\n### How to use the Frame Pacing library in native game engines\n\nSee the following guides to integrate the Android Frame Pacing library into your\ngame:\n\n- [Integrate Android Frame Pacing into your Vulkan renderer](/games/sdk/frame-pacing/vulkan)\n- [Integrate Android Frame Pacing into your OpenGL renderer](/games/sdk/frame-pacing/opengl)\n\n### How to use the Frame Pacing library in the Unity game engine\n\nUnity has integrated the Android Frame Pacing library into their engine. To enable this\nfeature in Unity, check the [Optimized Frame Pacing](https://docs.unity3d.com/Manual/class-PlayerSettingsAndroid.html) checkbox under *Project\nSettings \\\u003e Player \\\u003e Settings for Android \\\u003e Resolution and Presentation*:\n**Figure 7.** Enable Frame Pacing in Unity Engine.\n\nAlternatively, programmatically enable the\n[Optimized Frame Pacing option](https://docs.unity3d.com/ScriptReference/PlayerSettings.Android-optimizedFramePacing.html) in your logic code to allow\nUnity to evenly distribute frames for less variance in frame rate, creating\nsmoother gameplay.\n\n### **How to use the Frame Pacing library in Unreal game engine**\n\nUnreal 4.25 and later integrates the Android [Frame Pacing library](/games/sdk/frame-pacing), which is\npart of the [Android Game Development Kit](/games/agdk). The\n[Mobile Frame Pacing](https://docs.unrealengine.com/SharingAndReleasing/Mobile/Rendering/MobileFramePacing/) article explains how to enable the Android\nFrame Pacing library and how to control frame pacing from C++ code."]]