Skip to content

cmd/ebitenmobile: add an API to save GPU data and freeze the state until onResume is called #3372

@hajimehoshi

Description

@hajimehoshi

Operating System

  • Windows
  • macOS
  • Linux
  • FreeBSD
  • OpenBSD
  • Android
  • iOS
  • Nintendo Switch
  • PlayStation 5
  • Xbox
  • Web Browsers

What feature would you like to be added?

Currently, EbitenSurfaceView.onPause tries to save GPU data if necessary. This also invokes its super method GLSurfaceView.onPause. GLSurfaceView.onPause waits for its renderer thread finishing. Even if saving GPU is done on a renderer thread, onPause waits for it and the main thread is blocked. Apparently onPause is a very ANR-sensitive API and warns the application's freeze even if it takes only one second.

Instead, what about adding an API to save GPU asynchronously and pause Ebitengine state until next onResume? This means onPause and the main thread is no longer blocked, and we can avoid ANR issues. The new API will be explicitly invoked before onPause, e.g. when starting to show an ad.

Why is this needed?

Avoid blocking the main thread due to GLSurfaceView.onPause.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions