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

savePlaybackInfo NPE #341

Closed
DummyCo opened this Issue May 30, 2018 · 10 comments

Comments

Projects
None yet
3 participants
@DummyCo
Copy link

DummyCo commented May 30, 2018

Hi there! Getting rare crashes with next stacktrace:
Any suggestions?

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.application, PID: 8063
    java.lang.NullPointerException
        at im.ene.toro.ToroUtil.checkNotNull(ToroUtil.java:80)
        at im.ene.toro.widget.PlaybackInfoCache.savePlaybackInfo(PlaybackInfoCache.java:348)
        at im.ene.toro.widget.Container.savePlaybackInfo(Container.java:446)
        at im.ene.toro.widget.Container.onWindowVisibilityChanged(Container.java:552)
        at android.view.View.dispatchWindowVisibilityChanged(View.java:12133)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1487)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1491)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1686)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
        at android.view.Choreographer.doCallbacks(Choreographer.java:723)
        at android.view.Choreographer.doFrame(Choreographer.java:658)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
        at android.os.Handler.handleCallback(Handler.java:790)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6494)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
@eneim

This comment has been minimized.

Copy link
Owner

eneim commented May 30, 2018

@DummyCo Hm, good found. Do you have "CacheManager" in your setup?

The problem comes from the SpareArray tmpStates contains null value. And this array is set to the result of playbackInfoCache.saveStates(). So first i would like to investigate from the cache maps used in playbackInfoCache. Somehow it is updated with bad value ...

@DummyCo

This comment has been minimized.

Copy link

DummyCo commented May 30, 2018

@eneim using following configuration:

        SimpleCache cache = new SimpleCache(
                new File(getCacheDir() + "/toro_cache"),
                new LeastRecentlyUsedCacheEvictor(8 * 1024 * 1024)
        );

        toroExoPlayerConfig = new Config.Builder()
                .setMediaSourceBuilder(MediaSourceBuilder.LOOPING)
                .setCache(cache)
                .build();

        exoCreator = ToroExo
                .with(this)
                .getCreator(toroExoPlayerConfig);

And

container.setCacheManager(CacheManager.DEFAULT);

@eneim

This comment has been minimized.

Copy link
Owner

eneim commented Jun 2, 2018

@DummyCo It is quite difficult to reproduce, and in fact I've seen it once before (before releasing 3.5.0) but that time it was caused by an internal modification of the SparseArray and I fix that one.

Don't want to have a bunch of null check (which is against the correctness of implementation, and just hide the actual issue), but I consider that losing PlaybackInfo cache of one or two playback is less dumb than crashing the whole App, so I put a work around for it. Please try the latest 3.5.3-SNAPSHOT and see if you can reproduce the issue again?

@DummyCo

This comment has been minimized.

Copy link

DummyCo commented Jun 4, 2018

@eneim integrating & testing now, thank you, will share results ASAP!

@DummyCo

This comment has been minimized.

Copy link

DummyCo commented Jun 18, 2018

@eneim seems like no new issues spawned, thank you!

@eneim

This comment has been minimized.

Copy link
Owner

eneim commented Jun 19, 2018

Having not many time lately, I will consider to push something new in next few weeks ^^!

@gotamafandy

This comment has been minimized.

Copy link

gotamafandy commented Jun 26, 2018

hi @eneim i'm still getting the NPE for playback info (i'm using 3.5.3-snapshot)

java.lang.NullPointerException at im.ene.toro.ToroUtil.checkNotNull(ToroUtil.java:80) at im.ene.toro.widget.PlaybackInfoCache.savePlaybackInfo(PlaybackInfoCache.java:349) at im.ene.toro.widget.PlaybackInfoCache.restoreStates(PlaybackInfoCache.java:377) at im.ene.toro.widget.Container.onRestoreInstanceState(Container.java:682) at android.view.View.dispatchRestoreInstanceState(View.java:15755) at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:3251) at android.support.v7.widget.RecyclerView.dispatchRestoreInstanceState(RecyclerView.java:1338) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3237) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3237) at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3237) at android.view.View.restoreHierarchyState(View.java:15733) at android.support.v4.app.Fragment.restoreViewState(Fragment.java:415) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1454) at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1759) at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1827) at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:797) at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2596) at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2383) at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2338) at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2215) at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:649) at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:167) at android.support.v4.view.ViewPager.populate(ViewPager.java:1238) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:663) at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:625) at android.support.v4.view.ViewPager.setCurrentItem(ViewPager.java:606) at android.support.design.widget.TabLayout$ViewPagerOnTabSelectedListener.onTabSelected(TabLayout.java:2170) at android.support.design.widget.TabLayout.dispatchTabSelected(TabLayout.java:1165) at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1158) at android.support.design.widget.TabLayout.selectTab(TabLayout.java:1128) at android.support.design.widget.TabLayout$Tab.select(TabLayout.java:1427) at android.support.design.widget.TabLayout$TabView.performClick(TabLayout.java:1537) at android.view.View$PerformClick.run(View.java:22433) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:153) at android.app.ActivityThread.main(ActivityThread.java:6236) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:891) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:781)

I'm using nested player (similar to your nested example) with combination between image and video, and the Fragment are inside viewpager in tab layout with 1 page offset limit. Lets call this fragment as FeedFragment.

when moving to other tab, i saved the recyclerview layout manager layoutManager.onSaveInstanceState() inside onSaveInstanteState in FeedFragment as well, so that i can restore the position when going back to FeedFragment.

The crash mostly happened when i navigate away to other tab, which cause FeedFragment being removed by android system and then going back to that FeedFragment.

@eneim

This comment has been minimized.

Copy link
Owner

eneim commented Jul 2, 2018

@fandygotama-tokobagus I don't think manually call layoutManager.onSaveInstanceState(), it is called by RecyclerView already. I will investigate the NPE :-/.

@eneim

This comment has been minimized.

Copy link
Owner

eneim commented Aug 23, 2018

This issue should be fixed on 3.6.0.2802-SNAPSHOT.

@DummyCo

This comment has been minimized.

Copy link

DummyCo commented Sep 19, 2018

Hi, @eneim. Tested new version for a week or two, still no related issues spawned.
Seems to be resolved, thank you!

@DummyCo DummyCo closed this Sep 19, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment