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

ImaAdsLoader null pointer at ImaAdsLoader.stop when trying to call Player.removeListener #6308

Closed
amjadmasri opened this issue Aug 18, 2019 · 6 comments
Assignees
Labels

Comments

@amjadmasri
Copy link

[REQUIRED] Issue description

on crashlytics an increasingly large number of the following exception are popping up

Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'void com.google.android.exoplayer2.Player.removeListener(com.google.android.exoplayer2.Player$EventListener)' on a null object reference
       at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.stop + 630(ImaAdsLoader.java:630)
       at com.google.android.exoplayer2.source.ads.-$$Lambda$yBzHoZM9PK06K3WjH43AIns_6eA.run(lambda)
       at android.os.Handler.handleCallback + 739(Handler.java:739)
       at android.os.Handler.dispatchMessage + 95(Handler.java:95)
       at android.os.Looper.loop + 148(Looper.java:148)
       at android.app.ActivityThread.main + 7406(ActivityThread.java:7406)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1230(ZygoteInit.java:1230)
       at com.android.internal.os.ZygoteInit.main + 1120(ZygoteInit.java:1120)

the code for stopping and destroying is as follows :

@Override
    protected void onStop() {
       super.onStop();
        if(player!=null)
        player.release();
@Override
    protected void onDestroy() {
        super.onDestroy();
        if (imaAdsLoader != null)
            imaAdsLoader.release();
    }

[REQUIRED] Reproduction steps

it is unclear when and why the issue occurs so can't be reproduced by us for now
but it is normal behavior in our app to pause the player activity then show another activity
then return to the video player activity multiple times during content play

[REQUIRED] Link to test content

[REQUIRED] A full bug report captured from the device

[REQUIRED] Version of ExoPlayer being used

2.10.0

[REQUIRED] Device(s) and version(s) of Android being used

mostly it is happening on Samsung Galaxy Grand Prime Plus devices running Android 6 and 8 OS

@andrewlewis
Copy link
Collaborator

andrewlewis commented Aug 19, 2019

Looks like this happens if the ads loader's player is set to null before before AdsLoader.start runs on the main thread.

Update: actually this shouldn't be possible due to posting the start/stop runnables being serialized. I will investigate further.

@andrewlewis
Copy link
Collaborator

@amjadmasri It's not obvious how this can happen because it looks like ImaAdsLoader.stop would need to be called twice without a call to ImaAdsLoader.start. The other assignment of ImaAdsLoader.player in start has a null check.

Please could you check that the app isn't calling ImaAdsLoader.stop directly?

Do you see any failures of this assertion in your crash reports?

@amjadmasri
Copy link
Author

@andrewlewis thank you for your help
after checking the code and the crash reports
the app doesn't call ImaAdsLoader.stop directly
is there anything else that might be related that I can check if the app is calling wrong?

and we could only find this assertion failure in the reports , not sure if it is related


Fatal Exception: java.lang.IllegalArgumentException
       at com.google.android.exoplayer2.util.Assertions.checkArgument + 39(Assertions.java:39)
       at com.google.android.exoplayer2.ext.ima.ImaAdsLoader.onTimelineChanged + 955(ImaAdsLoader.java:955)
       at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.lambda$run$0$ExoPlayerImpl$PlaybackInfoUpdate + 790(ExoPlayerImpl.java:790)
       at com.google.android.exoplayer2.-$$Lambda$ExoPlayerImpl$PlaybackInfoUpdate$N_S5kRfhaRTAkH28P5luFgKnFjQ.invokeListener(lambda)
       at com.google.android.exoplayer2.BasePlayer$ListenerHolder.invoke + 165(BasePlayer.java:165)
       at com.google.android.exoplayer2.ExoPlayerImpl.invokeAll + 823(ExoPlayerImpl.java:823)
       at com.google.android.exoplayer2.ExoPlayerImpl.access$000 + 43(ExoPlayerImpl.java:43)
       at com.google.android.exoplayer2.ExoPlayerImpl$PlaybackInfoUpdate.run + 787(ExoPlayerImpl.java:787)
       at com.google.android.exoplayer2.ExoPlayerImpl.notifyListeners + 726(ExoPlayerImpl.java:726)
       at com.google.android.exoplayer2.ExoPlayerImpl.updatePlaybackInfo + 701(ExoPlayerImpl.java:701)
       at com.google.android.exoplayer2.ExoPlayerImpl.handlePlaybackInfo + 648(ExoPlayerImpl.java:648)
       at com.google.android.exoplayer2.ExoPlayerImpl.handleEvent + 598(ExoPlayerImpl.java:598)
       at com.google.android.exoplayer2.ExoPlayerImpl$1.handleMessage + 126(ExoPlayerImpl.java:126)
       at android.os.Handler.dispatchMessage + 102(Handler.java:102)
       at android.os.Looper.loop + 146(Looper.java:146)
       at android.app.ActivityThread.main + 5602(ActivityThread.java:5602)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke + 515(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run + 1283(ZygoteInit.java:1283)
       at com.android.internal.os.ZygoteInit.main + 1099(ZygoteInit.java:1099)
       at dalvik.system.NativeStart.main(NativeStart.java)

@andrewlewis
Copy link
Collaborator

Is that assertion from onTimelineChanged still happening? I thought it was fixed as the first issue discussed in #5831.

@amjadmasri
Copy link
Author

@andrewlewis sorry about that , but apparently it never got fixed completely.
at that time it happened more than 5k times to thousands of users
for each of the last three latest releases of our app it never happened more than 60 times for no more than 60 users. so it was missed while checking the reports and presumed fixed.

@andrewlewis
Copy link
Collaborator

andrewlewis commented May 18, 2020

@amjadmasri I think at the moment we don't have enough information to make this actionable, so I am going to close this issue. If you are still having problems with this, it would be helpful if you could pick up the changes to migrate to the new preloading API in fa7d26d (they should be in a release soon), check the error is still reproducible and file a new bug with any information you have. Thanks.

@google google locked and limited conversation to collaborators Jul 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants