Skip to content

Keep the Android app running while its window is hidden - #142

Merged
Try merged 2 commits into
Try:masterfrom
Solessfir:android-surface
Nov 11, 2026
Merged

Try merged 2 commits into
Try:masterfrom
Solessfir:android-surface

Conversation

@Solessfir

@Solessfir Solessfir commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #140, using the activity as the window handle as suggested there.

  • SystemApi::Window* on Android is now the ANativeActivity*, which lives as long as the activity. AndroidApi::nativeWindow() returns its current ANativeWindow, or null while the activity is hidden.
  • APP_CMD_TERM_WINDOW no longer closes the app: rendering just stops until NativeActivity provides a new window.
  • VSwapchain holds ANativeWindow_acquire on the window its surface was created from. On reset() it recreates the surface if the current window differs, and currentBackBuffer() throws SwapchainSuboptimal when it differs, so detection doesn't depend on the driver reporting anything.

About A-B-A: the swapchain's reference keeps the old window alive until the surface is destroyed, so a new window can't get the same address. If the same pointer comes back, it's the same window object, and the existing surface is still valid for it.

Comment thread Engine/gapi/vulkan/vswapchain.cpp Resolved
Comment thread Engine/system/api/androidapi.cpp Resolved
Comment thread Engine/system/api/androidapi.cpp Resolved
@Try
Try merged commit 5f2db69 into Try:master Nov 11, 2026
@Try

Try commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Merged, thanks!

@Solessfir
Solessfir deleted the android-surface branch November 11, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants