Closed la-matthew-yang closed 3 years ago
As an example, the following code can cause the same issue.
FileHandle testFile = Gdx.files.internal("test.mp3");
Music testMusic = Gdx.audio.newMusic(testFile);
testMusic.setOnCompletionListener(music -> {
testMusic.dispose();
});
testMusic.play();
I will try to look into it, thanks for reporting !
Thanks!
After further testing, I've noticed that this is not related to play().
The following code can reproduce the problem without calling play().
FileHandle testFile = Gdx.files.internal("test.mp3");
Music testMusic = Gdx.audio.newMusic(testFile);
testMusic.setOnCompletionListener(music -> {
});
testMusic.dispose();
In OboeMusic.setCompletionCallback(), old callback is disposed using context->DeleteGlobalRef(old_callback).
In OboeMusic.dispose(), callback is disposed using delete get_var_as
oboemusic.cpp:
OBOEMUSIC_METHOD(void, setCompletionCallback) (JNIEnv* env, jobject self, jobject callback) {
auto context = jni_context::acquire_thread();
auto old_callback = get_var_as<_jobject>(env, self, "onComplete");
if (old_callback != NULL) {
context->DeleteGlobalRef(old_callback) ;
}
auto new_callback = context->NewGlobalRef(callback);
set_var_as(env, self, "onComplete", new_callback);
auto instance = shared_ptr_var<music>(env, self, "music");
instance->on_complete([new_callback] {
auto context = jni_context::acquire_thread();
auto callback_class = jvm_class(context->GetObjectClass(new_callback));
callback_class.execute_method<void()>(new_callback, "invoke");
});
}
OBOEMUSIC_METHOD(void, dispose) (JNIEnv* env, jobject self) {
delete get_var_as<std::shared_ptr<music>>(env, self, "music");
delete get_var_as<jobject>(env, self, "onComplete");
}
Alright, fixed !
Will be in the next release 0.2.4 once I'm done with #2.
Feel free to reopen if you'll experience crashes with dispose()
again.
That's great news! Thanks a ton!
Is there any estimate on the release date? Would it be possible for you to kindly release a version with this fix in or post a copy of the so file for armeabi-v7a?
Estimate is this weekend (most probably this sunday). Copy of the so file won't work since there are changes on the kotlin side as well. If you need it asap, you can clone the repository and put a temporary local dependency in your project instead of the bintray one. You'll need to install NDK though.
Sunday is great. Thanks!
Thank you for creating this library! This library is great!
It crashes on sum devices, mostly on arm64 system. Below is the crash log:
[split_config.arm64_v8a.apk!liblibgdx-oboe.so] Java_barsoosayque_libgdxoboe_OboeAudio_pause
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
pid: 0, tid: 0 >>> com.myapp.test <<<
backtrace:
#00 pc 0x000000000005e8b4 /data/app/~~j7tklfpkB_MLQi1RF5VeUA==/com.myapp.test-yLtgSK985RacB_pwElM2nA==/split_config.arm64_v8a.apk!liblibgdx-oboe.so (Java_barsoosayque_libgdxoboe_OboeAudio_pause)
#01 pc 0x00000000001f315c /data/app/~~j7tklfpkB_MLQi1RF5VeUA==/com.myapp.test-yLtgSK985RacB_pwElM2nA==/oat/arm64/base.odex (art_jni_trampoline)
#02 pc 0x0000000000319a10 /data/app/~~j7tklfpkB_MLQi1RF5VeUA==/com.myapp.test-yLtgSK985RacB_pwElM2nA==/oat/arm64/base.odex (com.badlogic.gdx.backends.android.AndroidApplication$1.pause)
#03 pc 0x000000000038f990 /data/app/~~j7tklfpkB_MLQi1RF5VeUA==/com.myapp.test-yLtgSK985RacB_pwElM2nA==/oat/arm64/base.odex (com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame)
#04 pc 0x0000000000275f68 /data/app/~~j7tklfpkB_MLQi1RF5VeUA==/com.myapp.test-yLtgSK985RacB_pwElM2nA==/oat/arm64/base.odex (com.badlogic.gdx.backends.android.AndroidGraphics$1.run)
#05 pc 0x000000000063be60 /system/framework/arm64/boot-framework.oat (android.opengl.GLSurfaceView$GLThread.guardedRun)
#06 pc 0x000000000063ccf4 /system/framework/arm64/boot-framework.oat (android.opengl.GLSurfaceView$GLThread.run)
#07 pc 0x0000000000133564 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub)
#08 pc 0x00000000001a97e8 /apex/com.android.art/lib64/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*))
#09 pc 0x000000000055de54 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, art::ArtMethod*, jvalue const*))
#10 pc 0x00000000005adcd4 /apex/com.android.art/lib64/libart.so (art::Thread::CreateCallback(void*))
#11 pc 0x00000000000b0838 /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*))
#12 pc 0x00000000000505d0 /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread)
@Tonielro it appears to be not related to dispose()
? If that's the case, can you open a new issue with the same description as your comment, but also can you provide a repro ? I always struggle to reproduce crashes, especially if the crash is bound to hardware.
Thank you for creating this library! This library is great!
I've run into a problem with music disposal:
Environment: LibGdx Oboe 0.23, LibGdx 1.9.10
Error log: