user1803551
user1803551

Reputation: 13427

Crash with Gluon Attach Video Service

The class that uses the VideoService:

private final class MobileNotifier {

    private static final String SHORT_BEEP_PATH = "/sounds/ShortBeep.wav";
    private static final String LONG_BEEP_PATH = "/sounds/LongBeep.wav";

    VideoService service;

    MobileNotifier() {
        this.service = VideoService.create().get();
        service.getPlaylist().add(SHORT_BEEP_PATH);
    }

    public void alert(Alert alert) {
        switch (alert) {
            case NONE -> {
                System.out.println("NONE: stopping");
                service.stop();
                System.out.println("NONE: stopped");
            }
            case ORANGE -> play(alert, SHORT_BEEP_PATH);
            case RED -> play(alert, LONG_BEEP_PATH);
        };
    }

    private void play(Alert alert, String audioPath) {
        System.out.println(alert);
        if (!audioPath.equals(service.getPlaylist().get(0))) {
            if (service.statusProperty().get() != Status.PLAYING) {
                System.out.println(alert + ": not being played - stopping");
                service.stop();
                System.out.println(alert + ": not being played - stopped");
            }
            System.out.println(alert + ": setting");
            service.getPlaylist().set(0, audioPath);
            System.out.println(alert + ": set");
        }
        System.out.println(alert + ": playing");
        service.play();
        System.out.println(alert + ": played");
    }
}

The code switches between audio files to play based on the input it gets. void alert(Alert alert) is called about once per second. After a while, the app crashes on Android.

One time the crash produced this output with adb logcat -v brief -v color GraalCompiled:V GraalActivity:V GraalGluon:V GluonAttach:V AndroidRuntime:E ActivityManager:W *:S:

E/AndroidRuntime(29381): FATAL EXCEPTION: main
E/AndroidRuntime(29381): Process: com.gps.demo, PID: 29381
E/AndroidRuntime(29381): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.media.MediaPlayer.setSurface(android.view.Surface)' on a null object reference
E/AndroidRuntime(29381):        at com.gluonhq.helloandroid.DalvikVideoService.onSurfaceTextureAvailable(DalvikVideoService.java:381)
E/AndroidRuntime(29381):        at android.view.TextureView.getHardwareLayer(TextureView.java:390)
E/AndroidRuntime(29381):        at android.view.TextureView.draw(TextureView.java:339)
E/AndroidRuntime(29381):        at android.view.View.updateDisplayListIfDirty(View.java:19315)
E/AndroidRuntime(29381):        at android.view.View.draw(View.java:20093)
E/AndroidRuntime(29381):        at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
E/AndroidRuntime(29381):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
E/AndroidRuntime(29381):        at android.view.View.draw(View.java:20373)
E/AndroidRuntime(29381):        at android.view.View.updateDisplayListIfDirty(View.java:19315)
E/AndroidRuntime(29381):        at android.view.View.draw(View.java:20093)
E/AndroidRuntime(29381):        at android.view.ViewGroup.drawChild(ViewGroup.java:4421)
E/AndroidRuntime(29381):        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4207)
E/AndroidRuntime(29381):        at android.view.View.draw(View.java:20373)
E/AndroidRuntime(29381):        at com.android.internal.policy.DecorView.draw(DecorView.java:980)
E/AndroidRuntime(29381):        at android.view.View.updateDisplayListIfDirty(View.java:19315)
E/AndroidRuntime(29381):        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
E/AndroidRuntime(29381):        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
E/AndroidRuntime(29381):        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:800)
E/AndroidRuntime(29381):        at android.view.ViewRootImpl.draw(ViewRootImpl.java:3496)
E/AndroidRuntime(29381):        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3283)
E/AndroidRuntime(29381):        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2818)
E/AndroidRuntime(29381):        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1780)
E/AndroidRuntime(29381):        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7827)
E/AndroidRuntime(29381):        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
E/AndroidRuntime(29381):        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
E/AndroidRuntime(29381):        at android.view.Choreographer.doFrame(Choreographer.java:658)
E/AndroidRuntime(29381):        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
E/AndroidRuntime(29381):        at android.os.Handler.handleCallback(Handler.java:789)
E/AndroidRuntime(29381):        at android.os.Handler.dispatchMessage(Handler.java:98)
E/AndroidRuntime(29381):        at android.os.Looper.loop(Looper.java:164)
E/AndroidRuntime(29381):        at android.app.ActivityThread.main(ActivityThread.java:6944)
E/AndroidRuntime(29381):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(29381):        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
E/AndroidRuntime(29381):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
W/ActivityManager( 1525): crash : com.gps.demo,0
W/ActivityManager( 1525):   Force finishing activity com.gps.demo/com.gluonhq.helloandroid.MainActivity

When trying to look deeper with adb logcat -v color a couple of times, I got the crash detailed here: https://pastebin.com/2dLmHaQX (the log is too long to post here).

It seems that at some point the video service enters an illegal state. I did not get a crash when using AudioService, but that service does not allow changing the volume with the volume keys.

Using

        <gluonfx-maven-plugin-version>1.0.15</gluonfx-maven-plugin-version>
        <java-version>17</java-version>
        <javafx-version>19</javafx-version>
        <charm-version>6.2.2</charm-version>
        <attach-version>4.0.15</attach-version>

With javafxStaticSdkVersion 19 and using graalvm-svm-java17-linux-gluon-22.1.0.1-Final. Running on Android 8 through 12.

Upvotes: 0

Views: 23

Answers (0)

Related Questions