Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AndroidFragmentApplication dies onPause #7342

Open
1 of 6 tasks
rdeo-aziwell opened this issue Feb 15, 2024 · 0 comments
Open
1 of 6 tasks

AndroidFragmentApplication dies onPause #7342

rdeo-aziwell opened this issue Feb 15, 2024 · 0 comments

Comments

@rdeo-aziwell
Copy link

rdeo-aziwell commented Feb 15, 2024

Issue details

Using an AndroidFragmentApplication causes the app to kill itself when onPause is called.
Error log: waiting for pause synchronization took too long; assuming deadlock and killing

Reproduction steps/code

class GameFragment: AndroidFragmentApplication() {
    private val game = Game()

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        super.onCreateView(inflater, container, savedInstanceState)
        return initializeForView(game)
    }

    override fun onPause() {
        // Dies after onPause
        super.onPause()
    }
}

Fragment is used in Compose app like this:

AndroidViewBinding(GameFragmentBinding::inflate)

Workaround

Crash can be avoided by manually calling onDrawFrame

override fun onPause() {
   val job = scope.launch {
      while(coroutineContext.isActive) {
         (Gdx.graphics as AndroidGraphics).onDrawFrame(null)
         yield()
      }
   }
   super.onPause()
   job.cancel()
}

Version of libGDX and/or relevant dependencies

1.12.1

Stacktrace

AndroidGraphics.java(414): Gdx.app.error(LOG_TAG, "waiting for pause synchronization took too long; assuming deadlock and killing");

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • macOS
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

No branches or pull requests

1 participant