Optimize Runtime Performance
Find and reduce stutters, scene loading waits, and memory pressure while your game runs. This guide applies to Unity, Cocos, and JavaScript mini games.
This guide is part of Optimize Mini Game Performance. For launch waits, see Optimize Startup.

Prerequisites
- A mini game that runs in Client preview on a phone
- A test account authorized for your app
- For released games: access to Mini Games Analytics
Reproduce the problem
Reproduce the slowdown on a real phone, find the frame or transition that causes it, and check one targeted fix at a time.
Choose a scene and action that reproduce the issue. Record the screen, and note the action, the visible pause, and how often it happens.
- Record the game build, engine and SDK versions, phone model, operating system, TikTok version, and whether you used Client preview or Platform Preview.
- Repeat the same path with the same graphics settings. For loading problems, record the network and whether the resources were already cached.
- In the TikTok app preview, open … > Developer options and turn on Show DevInfo Panel and Show vConsole. For details, see Debug Your Mini Game. Replay the action, and check the runtime FPS and logs. If the wait happens during the first launch or a cold revisit, measure first paint and time to interactive instead. For details, see Optimize Startup.
Use the right measurement. FPS is the number of frames rendered per second. Frame time is the time spent on one frame. A short spike in frame time can be noticeable even when the average FPS is high.
Note: A memory warning signals system memory pressure. It doesn't report exact memory use, and it doesn't prove that the game crashed.
For a released game, Mini Games Analytics shows aggregate FPS and stutter rate. Check the filters, time range, and report count before you compare versions.
Find the work behind a stall
At the action where the stall happens, check the following work. Change one suspected cause, rebuild, and replay the same action.
What happens | What to check | What to try |
A tap or gameplay action pauses briefly. | Scripts, UI updates, synchronous processing, and object creation around that action. | Update score and health UI only when the values change. Move unrelated calculations and object creation away from the input event. |
The first skill, visual effect, or combat hit freezes briefly. | Shader variants compiled on demand, prefabs instantiated on first use, or audio decoded synchronously. | Before interactive combat begins, warm up only the shader variants combat needs, and fill the pools for effects used on first hit, instead of compiling on the first hit. |
Stalls repeat when objects appear or disappear. | Repeated allocation, destruction, and temporary data in projectiles, obstacles, effects, or list updates. | Track the peak number of objects in the scene at the same time. Reuse projectiles and effects through a pool with a fixed size. Reset their state and release unused entries. |
A busy scene slows down. | Draw calls, material and texture switches, transparency, particle overdraw, shadows, and render resolution. | Turn off one expensive effect, such as shadows or particles, and replay the scene. For UI, check the atlas, materials, masks, and node order before batching. |
The game stalls during a request or while it prepares assets. | When downloads, file reads, JSON parsing, and object creation run compared with player input. | Move downloads, parsing, and bulk object creation that aren't urgent away from frames that handle input. Have required assets ready before use, and provide a retry if loading fails. |
The game stalls, audio stays muted, or input freezes after an ad closes. | The ad close callback, scene rebuilds, paused audio or | In the close callback, restore audio, |
For Unity, check frame spikes in the Unity 6 Profiler or the Unity 2022 LTS Profiler when your build supports it. For Cocos UI, see Cocos Creator 3.8 UI batching.
Reduce scene and resource loading waits

- Identify the assets the next scene requires, and when the player's next destination becomes predictable. Prepare them only when gameplay has enough processing time, network capacity, and memory to spare.
- In your investigation, separate downloading, parsing, creating objects, and entering the scene. Downloading a file is only one part of making a scene ready.
- For JavaScript projects that use subpackages, see Subpackage Loading.
preDownloadSubpackage()downloads a subpackage.loadSubpackage()also runs its entry. Your engine might still have to process assets and initialize the scene. - For Cocos Asset Bundles, load the next scene's bundle before you enter the scene. For Unity, load the next scene's assets through your project's loader. Keep shared assets until the current scene exits.
- Show a usable transition while the required work finishes. If loading fails, offer a retry or a way back. Cancel or ignore work for a destination the player abandons.
Test the transition on a phone with cached and uncached resources, and with a failed request where it applies. Check that the new scene appears, that controls respond, and that the previous scene's resources are released when they're no longer needed.
For package layout and remote asset caching, see Manage Packages and Assets, Cocos Creator 3.8 Asset Bundles, and the Unity Addressables 2.7 guide.
Control memory during play
Enter and leave the same scene repeatedly. Check whether its objects, assets, timers, and listeners remain after it exits.
- Cocos Creator 3.8: Select the scene in Assets, turn on Auto Release Assets in its properties, and select Apply. Manage dynamic references with
addRefanddecRef, and keep assets that another scene still uses. For details, see Cocos resource release. - Unity: Release finished level handles with
Addressables.ReleaseorAssetBundle.Unload(false). CallResources.UnloadUnusedAssets()only at scene transitions, never every frame, so the old and new scene bundles don't stay in memory together.
For all engines:
- Release scene-owned resources: Stop timers, remove listeners, and release assets and objects that are no longer referenced. Keep shared resources that another scene still uses.
- Limit pools and caches: Measure peak use during representative gameplay, then cap the objects and cached assets you keep. Keep player saves separate from disposable asset caches. Never call
clearStorageto free asset memory. - Limit prepared content: Don't hold several upcoming levels in memory when the player is unlikely to need them. Check memory while the old and new scenes overlap.
- Check late callbacks: When an asynchronous load finishes after the scene changes, check that the result still belongs to the active scene before you apply it.
Respond to a memory warning in JavaScript
The Memory API can notify your game of system memory pressure. In your own game code, release unused assets or reduce further preparation. The callback doesn't report memory use.
Register one listener during setup. Add your game's cleanup for unused assets inside the callback, and remove the listener when the component that owns it is disposed.
const onMemoryWarning = () => {
// Release your game's unused assets here.
};
if (typeof TTMinis.game.onMemoryWarning === "function" &&
typeof TTMinis.game.offMemoryWarning === "function") {
TTMinis.game.onMemoryWarning(onMemoryWarning);
}
function disposeMemoryListener() {
if (typeof TTMinis.game.offMemoryWarning === "function") {
TTMinis.game.offMemoryWarning(onMemoryWarning);
}
}Test cleanup on your target devices. A warning doesn't guarantee that cleanup finishes before the operating system acts.
Pause and resume background work
When the player leaves the game, pause timers, polling, audio, and asset preparation the game doesn't need, as appropriate. Keep the state needed to resume.
When the player returns, restore the work without adding a second update loop or duplicate event listeners.
JavaScript games can use onHide and onShow to handle moving to the background and foreground. Keep references to registered callbacks so you can remove them later.
On a phone, leave the game during an active scene and while a resource request is pending. Return, and check controls, audio, timers, pending operations, and the scene state. Repeat the transition to find duplicated tasks.
Compare before and after
- Run the original player path with the same device, entry, build configuration, scene, and graphics settings. For loading changes, keep network and cache conditions comparable.
- Compare the visible pause or wait with the frame time, FPS, request, or engine data you have. Keep several observations, and don't report only the best run.
- After the change, check the first and later scenes, touch input, audio, and related save or platform flows. When you change loading, test the failure and retry paths.
- Repeat on the iOS and Android devices that matter for your game. Record the change, its result, any quality or memory tradeoffs, and the paths you didn't test.
If the issue remains, keep the original recording. Collect the game and SDK versions, the device and TikTok versions, the entry, the time, the steps, and relevant logs, and contact Developer Support. Remove private player information from logs and recordings before you share them.
References
- Frame Rate: Set a preferred frame rate in JavaScript when appropriate. A target frame rate isn't a measurement or a fix for stutter.
- Memory: Register and remove memory warning listeners.
- Event: Handle moving to the background and foreground.
- Subpackage Loading: Download and load subpackages.
- Mini Games Analytics: Review aggregate performance metrics where available.
- Optimize Mini Game Performance: An overview of startup, gameplay, ads, and revisits.
- Optimize Startup: Reduce launch waits, and measure first paint, time to interactive, and cache reuse.
- Manage Packages and Assets: Configure subpackages, remote asset caching, and versioned updates.