Skip to content

Fix Android 'Swapchain lost' crash and mitigate log flooding - #241

Merged
winnerspiros merged 1 commit into
masterfrom
fix/android-surface-loss-crash-690584439121913596
Apr 22, 2026
Merged

Fix Android 'Swapchain lost' crash and mitigate log flooding#241
winnerspiros merged 1 commit into
masterfrom
fix/android-surface-loss-crash-690584439121913596

Conversation

@google-labs-jules

Copy link
Copy Markdown

This PR addresses the "Swapchain's underlying surface has been lost" crash observed on Android devices (specifically S23 Ultra) during startup. The crash was caused by a race condition where the Vulkan renderer attempted to initialize using a surface handle that was immediately invalidated by the initial orientation rotation.

Key fixes:

  1. Surface Lifecycle: Readiness signal (surfaceEvent.Set()) is now delayed until SurfaceChanged confirms valid dimensions.
  2. Surface Cleanup: Explicitly clearing global JNI refs and resetting the event in SurfaceDestroyed to prevent stale handle usage.
  3. Orientation: Switched to fixed Landscape in manifest and forced it in OnCreate to suppress the "Portrait -> Landscape" hop on startup.
  4. Log Mitigation: Implemented exception deduplication in CrashDiagnostics to prevent 1GB log files during crash loops by rate-limiting repeated exceptions to 10 entries each.
  5. Noise Filtering: Suppressed macOS-specific HidSharp exceptions that were cluttering Android logs.

PR created automatically by Jules for task 690584439121913596 started by @winnerspiros

- Fixed OsuGameActivity orientation to Landscape in manifest and OnCreate to prevent startup surface recreation.
- Delayed surface readiness signal to SurfaceChanged with width/height validation.
- Added explicit surface handle cleanup in SurfaceDestroyed to prevent stale usage.
- Implemented exception deduplication in CrashDiagnostics to prevent 1GB log files during crash loops.
- Suppressed HidSharp macOS-specific noise exceptions in managed hooks.
@google-labs-jules

Copy link
Copy Markdown
Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@winnerspiros
winnerspiros merged commit b519f0c into master Apr 22, 2026
13 of 15 checks passed
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.

1 participant