Skip to main content
Version: Next (dev)

Android Runtime

This page describes how an exported game behaves on an Android device and what you can tune: pausing, render resolution, input, the safe area, logging, device cvars and the mobile render path.

Home, Recents and Screen Off​

When the player presses Home, opens the recent apps or turns the screen off, Android takes the window away. The game keeps running in the background without drawing:

  • The open frame is finished, then the window and swap chain are released (Android: window released, game paused in logcat). The world, resources and GPU device stay alive.
  • The game does not update while the window is gone or the activity is paused, so game time does not advance.
  • Sound pauses while the app is paused or loses focus, and returns to its previous state afterwards.
  • Every finger and key is released, because the system takes the touch stream away.

When the player returns, the window and swap chain are recreated (Android: window recreated, game resumed) and the game continues where it was. When Android reports low memory, the engine frees every unused resource. Each launch starts a fresh process.

Render Resolution​

Phones have very high-resolution displays. By default the game renders at half the display resolution, and the display compositor scales the picture up to the screen. The size from Window.ddl or the game settings does not apply on Android.

CvarDefaultDescription
Android.RenderScale0.5Swap chain size relative to the display, from 0.25 to 1. Applied when the window is created or resized. Saved.
Android.FrameRate60The frame rate the game asks the display for (Android 11+). 0 leaves it to the system. Saved.

The log shows the result, for example Android window: surface 2400x1080, swap chain 1200x540 (Android.RenderScale 0.5). The window follows rotation and multi-window resizes.

Input​

Touch​

The device has ten touch points, touchpoint_0 to touchpoint_9, each with touchpoint_N_position_x and touchpoint_N_position_y in the range 0 to 1. A tap that goes down and up between two frames still counts as one press. When the system cancels a touch, for example for a gesture, every finger is released.

An input action of a legacy input set can be limited to an area of the screen. In Project > Project Settings > Legacy Input Configuration..., give the action an Area X and Area Y range (0 to 1) and, per slot, the position slot that must lie inside it. For example, touchpoint_0 filtered by touchpoint_0_position_x from 0 to 0.5 only triggers on the left half of the screen. Area-filtered slots share their touch point with other actions instead of taking it exclusively.

Game UI has on-screen touch joysticks and touch buttons that feed input slots, shown only on touch devices. See the Game UI documentation.

A project without a game state of its own gets a touch camera: the left half of the screen moves, the right half turns the view.

Back button​

The Android Back button maps to keyboard_escape. Escape closes the app, unless the game state handles it itself, for example by opening the pause menu. Back or Select on a gamepad maps to controller0_button_back instead.

Keyboard and gamepad​

Physical keyboards and the soft keyboard map to the usual keyboard_* slots. Volume and power keys stay with the system.

Up to four gamepads are supported, with face buttons, Start, Back/Select, shoulders, triggers, both sticks, stick buttons and the d-pad. Vibration is not supported. The gamepad's home button belongs to the system.

Soft keyboard​

Game UI shows the soft keyboard automatically while a text input element has focus. In C++, plSoftKeyboard::Show() and plSoftKeyboard::Hide() open and close it, and plSoftKeyboard::IsSupported() says whether the device has one.

Immersive Mode and Safe Area​

By default the game hides the status and navigation bars and draws behind the display cutout. A swipe from the edge shows the bars for a moment.

CvarDefaultDescription
Android.ImmersivetrueHides the status and navigation bars and lets the game cover the display cutout. Applied when the window gains focus.

Because the game covers the whole display, parts of the picture can lie under a camera cutout or rounded corner. plSafeArea::GetCurrent() (C++) returns the insets on each side as fractions of the window width and height (all zero on other platforms). Game UI touch controls stay inside the safe area automatically. Keep other important UI inside it too.

Logging​

The engine writes its log to logcat with the tag plEngine, at INFO priority. Errors are logged at ERROR and crash reports at FATAL. Production phones often drop DEBUG lines, so engine lines use INFO.

adb logcat -s plEngine

When the game crashes, the crash handler logs the signal, the fault address and, on arm64, the program counter as library and offset for llvm-addr2line. Then it hands over to the system, which still writes its tombstone. No minidump is written on Android.

In the editor, the Logcat tab of the log panel shows the device log while the remote engine process runs on a phone.

Thermal Headroom​

On Android 11 and newer, the engine publishes the stat Android/ThermalHeadroom every two seconds: 0 means the device is cool, 1 means it is about to throttle. Watch it in the stats view of the Inspector. The Device Run window also reports the battery temperature at the start and end of a run.

Connecting the Inspector​

Development builds can be inspected over the USB cable. In the Inspector's connection window, an attached phone appears as USB: <model> (<serial>). Pick it, or connect to adb:<serial> (adb: alone picks the only attached device). The Inspector forwards the port through adb and reconnects when the game restarts.

Android Defaults​

On every start, before the game's own settings, an Android build sets cvars that suit phones. They turn off features that are too expensive or not supported on mobile GPUs and turn on the mobile optimisations:

ValueCvars
onApp.VSync, Rendering.Mobile.ShadingTier, Rendering.RenderGraph.AutoDiscard, Rendering.RenderGraph.AutoLoadDontCare, Rendering.RenderGraph.TransientAttachments, Rendering.Pipelines.AsyncCompile
offRendering.RT.Enable, Rendering.GI.Enabled, Rendering.GI.RTGI.Enabled, Rendering.GI.Specular.Enabled, Rendering.Culling.GPU, Rendering.MeshShaders, Rendering.Shadows.UseVirtualShadowMaps, Rendering.VolumetricClouds.Enabled, Rendering.AsyncQueues, Rendering.AsyncCompute
0Rendering.GI.Diffuse.Technique, Rendering.Forward.ShadingQuality
1Rendering.Shadows.Quality (medium)
2Rendering.GI.Specular.Technique, Rendering.RecordingThreads

Rendering.Shadows.Quality stays at 1 on Android: the exported shaders are compiled for medium shadows, and the game settings reject other values.

Development Tools on the Device​

These tools exist only in Development and Debug builds, not in Shipping.

Frame statistics​

CvarDefaultDescription
App.LogFrameStats0Every N seconds, logs one `PL_FRAMESTATS
App.LogFrameStats.PrefixesRenderer/GPU/;RenderContext/Which stats the PL_FRAMESTATS+ lines include, as ;-separated prefixes. Add Android/ for the thermal headroom.

App.LogFrameStats works on every platform. The Device Run window turns it on to measure a run. App.ShowFPS also works without the Inspector plugin.

Device cvars​

To change cvars on a phone without rebuilding, write Name = Value lines into DeviceCVars.cfg in the app's user data folder (:appdata). For a game that runs on the engine's Player this is files/plPlayer/ in the app's private storage. It is applied after the Android defaults and again after the game settings write their quality cvars, so it wins over both:

adb shell "run-as com.studio.game sh -c 'mkdir -p files/plPlayer && echo \"Android.RenderScale = 0.75\" > files/plPlayer/DeviceCVars.cfg'"

While the game runs, it also checks its data folder every half second for Remote.cfg (cvar assignments) and Remote.exec (console commands, one per line), applies them and deletes the files.

Mobile Render Path​

The Render path setting on the Android app tab chooses how the game renders:

Render pathPipelineQuality preset
Mobile (default)RenderPipelines/MobileRenderPipeline (Base data): a forward pipeline for tile-based mobile GPUs, with mobile shading, automatic discard of attachments and transient attachmentsMobile
DesktopMainRenderPipeline, as on PCthe project's default

New Android asset profiles use the mobile pipeline. The setting writes the profile's main render pipeline; a custom pipeline set in the profile is kept.

The Mobile quality preset is the Low preset with motion blur off, medium shadows with one cascade, no local light shadows, the cheapest depth of field and contact shadows, reduced guided lighting and no virtual shadow maps. It is offered only on Android and is the Android default. A project's QualityPresets.ddl can choose another one with Default.Android. See Quality Presets.

The Textures setting chooses the ASTC block size of the Android asset profile (AndroidCompression). ASTC 6×6 with 4×4 normal maps is the default.

On the device, the driver's pipeline cache is saved whenever pipeline creation goes quiet (Android can stop an app without warning), and it is reused on the next launch until the driver changes. Together with the pipeline prewarm list, this keeps hitches down after the first launch.

Data and Asset Packs at Runtime​

With Pack data into archives on, each data directory ships as .plArchive files that the game reads in place from the APK and its install-time asset packs, without unpacking them first. Plugins also load straight from the APK.

Asset packs at runtime​

Fast-follow and on-demand packs arrive after the install. When one arrives, the engine mounts it, reloads resources and logs Asset pack 'X' mounted from '...'. Fast-follow packs are fetched automatically. On-demand packs are fetched when the game asks for them.

APIDescription
plAndroidAssetDelivery::RequestPack(sPack)Asks Google Play for a pack.
plAndroidAssetDelivery::GetState(sPack) / GetProgress(sPack)The pack's state and download progress.
plAndroidAssetDelivery::GetPacks()The packs of the app.
plAndroidAssetDelivery::s_EventsSends plAssetPackEvent (pack, state, progress) when a pack changes.
Script class AssetPacksRequestAssetPack(Pack), IsAssetPackInstalled(Pack), GetAssetPackProgress(Pack).

The states are NotInstalled, Pending, Downloading, Transferring, Installed, Failed, Canceled, WaitingForWifi, RequiresUserConfirmation and Unknown. On other platforms every pack reports Installed, so the same game code works everywhere.

Development builds have the console commands AssetPackRequest <pack> and AssetPackStatus.

Launch splash​

The system launch splash stays on screen until the game has shown its first frame (the boot image, or the first frame of the game world), so there is no black screen between splash and game. If the game does not present a frame within 30 seconds, the splash goes away anyway.

See Also​