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

[BUG]: Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference #3901

Closed
maxinminax opened this issue Jun 12, 2024 · 9 comments · Fixed by #3931
Labels

Comments

@maxinminax
Copy link

Version

6.2.0

What platforms are you having the problem on?

Android

System Version

9,10,12,13

On what device are you experiencing the issue?

Real device

Architecture

Old architecture

What happened?

Exception java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()' on a null object reference
at android.content.ComponentName. (ComponentName.java:133)
at android.content.Intent. (Intent.java:7425)
at com.brentvatne.exoplayer.VideoPlaybackService.createSessionNotification (VideoPlaybackService.kt:118)
at com.brentvatne.exoplayer.VideoPlaybackService.onUpdateNotification (VideoPlaybackService.kt:88)
at androidx.media3.session.MediaSessionService.onUpdateNotificationInternal (MediaSessionService.java:538)
at androidx.media3.session.MediaNotificationManager$MediaControllerListener.onEvents (MediaNotificationManager.java:335)
at androidx.media3.session.MediaControllerImplBase.lambda$new$0$androidx-media3-session-MediaControllerImplBase (MediaControllerImplBase.java:157)
at androidx.media3.session.MediaControllerImplBase$$ExternalSyntheticLambda85.invoke
at androidx.media3.common.util.ListenerSet$ListenerHolder.iterationFinished (ListenerSet.java:350)
at androidx.media3.common.util.ListenerSet.handleMessage (ListenerSet.java:294)
at androidx.media3.common.util.ListenerSet.$r8$lambda$bio3pd12v5B_9b5UeFaPn9XBQ90
at androidx.media3.common.util.ListenerSet$$ExternalSyntheticLambda0.handleMessage
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loopOnce (Looper.java:240)
at android.os.Looper.loop (Looper.java:351)
at android.app.ActivityThread.main (ActivityThread.java:8377)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:584)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1013)

Reproduction

No response

Reproduction

showNotificationControls={true} on Android

@maxinminax maxinminax added the bug label Jun 12, 2024
@freeboub
Copy link
Collaborator

can you please tell me which react native version do you use ?
Do you have multiple Video views in your app ?

@freeboub
Copy link
Collaborator

@paulrinaldi @KrzysztofMoch I am reviewing the code, there is something I can point regarding to this crash:
in registerPlayer we always set the sourceActivity, in unregisterPlayer we clear sourceActivity.
In case of multiplayer usage, the second player removal can clear sourceActivity then the first player will lost the value !
can you please have a quick look on what I am saying ?

@maxinminax
Copy link
Author

can you please tell me which react native version do you use ? Do you have multiple Video views in your app ?

I'm using react-native version 0.74.2, and only once video view

@arsensgitacc
Copy link

@freeboub I have same crashes reported in Crashlytics. I was able to reproduce. When I have 2 videos in notification, then closing one and resuming another makes the crash.

@freeboub
Copy link
Collaborator

@arsensgitacc can you please try this patch, I think it will fix the issue

    fun unregisterPlayer(player: ExoPlayer) {
        hidePlayerNotification(player)
        val session = mediaSessionsList.remove(player)
        session?.release()
-        sourceActivity = null

        if (mediaSessionsList.isEmpty()) {
            cleanup()
            stopSelf()
        }
    }

@arsensgitacc
Copy link

@freeboub yeah, not crashing anymore. Thanks!!
Do you see any side effects of not setting sourceActivity to null? :D

@freeboub
Copy link
Collaborator

I don't think so, but I would like a feedback from @KrzysztofMoch and / or @paulrinaldi

@paulrinaldi
Copy link
Contributor

I couldn't reproduce this problem on my physical device or simulator. I tested the patch in simulator and notifs work fine for me (closing notif, close a video and reopen a new video).

I agree that this null assignment should be unnecessary as well since it is set to null in the beginning of the kotlin file. Though, I have less kotlin experience than Java...

LGTM

@freeboub
Copy link
Collaborator

Thank you @paulrinaldi , I will open a PR with this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants