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

Crash when starting app on some devices #14

Open
dasisdormax opened this issue Jul 24, 2022 · 3 comments
Open

Crash when starting app on some devices #14

dasisdormax opened this issue Jul 24, 2022 · 3 comments
Assignees

Comments

@dasisdormax
Copy link
Contributor

Hello and first of all, Thanks for creating this library!

Using libgdx-oboe from current master, my game crashes when launching on some, but not all of my devices. The error happens on a OnePlus 6 running Android 11. This is the message:

java.lang.RuntimeException: Unable to resume activity {...}: com.badlogic.gdx.utils.GdxRuntimeException: Error starting stream: ErrorInvalidState
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4636)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4668)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:233)
        at android.app.ActivityThread.main(ActivityThread.java:8068)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
     Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error starting stream: ErrorInvalidState
        at barsoosayque.libgdxoboe.OboeAudio.resume(Native Method)
        at com.badlogic.gdx.backends.android.AndroidApplication.onResume(AndroidApplication.java:265)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1571)
        at android.app.Activity.performResume(Activity.java:8141)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4626)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4668) 
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:233) 
        at android.app.ActivityThread.main(ActivityThread.java:8068) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) 

When rolling back to commit c09f42c, the app works normal on my devices. So this looks like an error introduced when fixing issue #12.

When researching a bit more I found out:

  • That device calls resume when launching the app while other devices don't
  • Calling audio.resume() twice crashes the app

Changing the resume function to do nothing instead of crashing when already resumed would seem like a good solution to me.

@barsoosayque
Copy link
Owner

Oh, thanks for the detailed report. Yeah, seems like starting an oboe stream too early could lead to crashes on some devices (the audio stack on android is cursed indeed). I admit I didn't research much before fixing #12. I'll try to look into it more

@barsoosayque barsoosayque self-assigned this Jul 28, 2022
@barsoosayque
Copy link
Owner

Finally, I got time for this issue. I'm still not sure what is wrong, but I made internal oboe checks to log warnings instead of throwing an exception so it won't crash. But I assume that in those rare cases when it were crashing before, now it just wouldn't play any sound. Can you test the current master ? I just don't seem to reproduce this issue myself

@dasisdormax
Copy link
Contributor Author

Hi. I finally got to try the current master build.

I did not get any crashes with this build. However, I sometimes had no music playing initially (this time on my weak Amazon tablet), with the audio starting later once another sound is scheduled.

I think this is not as bad and much better than having crashes sometimes. Thanks for your fix!

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

2 participants