GithubHelp home page GithubHelp logo

Comments (10)

la-matthew-yang avatar la-matthew-yang commented on June 22, 2024

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();

from libgdx-oboe.

barsoosayque avatar barsoosayque commented on June 22, 2024

I will try to look into it, thanks for reporting !

from libgdx-oboe.

la-matthew-yang avatar la-matthew-yang commented on June 22, 2024

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(env, self, "onComplete").
Maybe this is causing the issue?

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");
}

from libgdx-oboe.

barsoosayque avatar barsoosayque commented on June 22, 2024

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.

from libgdx-oboe.

la-matthew-yang avatar la-matthew-yang commented on June 22, 2024

That's great news! Thanks a ton!

from libgdx-oboe.

la-matthew-yang avatar la-matthew-yang commented on June 22, 2024

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?

from libgdx-oboe.

barsoosayque avatar barsoosayque commented on June 22, 2024

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.

from libgdx-oboe.

la-matthew-yang avatar la-matthew-yang commented on June 22, 2024

Sunday is great. Thanks!

from libgdx-oboe.

Tonielro avatar Tonielro commented on June 22, 2024

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)

from libgdx-oboe.

barsoosayque avatar barsoosayque commented on June 22, 2024

@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.

from libgdx-oboe.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.