Version used: ViewPager2 1.1.0-alpha01, Fragment 1.4.0-alpha03
Devices/Android versions reproduced on: LGE LM-X525 running Android 10
My app, Muzei uses a ViewPager2 with just two tabs on just one screen. I am using the "Fragment StrictMode" feature introduced in Fragment 1.4.0-alpha01 to detect Fragment reuse (i.e., adding a Fragment instance that was previous removed from the FragmentManager) and hooked that up to non-fatal crash reporting. I got two reports from one device that this was being violated by ViewPager2:
Non-fatal Exception: androidx.fragment.app.strictmode.FragmentReuseViolation: Attempting to reuse fragment EffectsScreenFragment{e9f23e4} (b74813a6-11c9-4f9c-807c-47d5095919eb tag=f0) with previous ID 6a08d652-13f3-4522-b52c-14bd7064feb9
at androidx.fragment.app.strictmode.FragmentStrictMode.onFragmentReuse(FragmentStrictMode.java:296)
at androidx.fragment.app.FragmentManager.addFragment(FragmentManager.java:1365)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:387)
at androidx.fragment.app.FragmentManager.executeOps(FragmentManager.java:1856)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1764)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1708)
at androidx.fragment.app.FragmentManager.execSingleAction(FragmentManager.java:1620)
at androidx.fragment.app.BackStackRecord.commitNow(BackStackRecord.java:317)
at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:353)
at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:284)
at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:72)
at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7867)
at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:893)
at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8902)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8860)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1647)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1395)
at androidx.recyclerview.widget.LinearLayoutManager.scrollHorizontallyBy(LinearLayoutManager.java:1124)
at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1969)
at androidx.recyclerview.widget.RecyclerView$SmoothScroller.onAnimation(RecyclerView.java:12316)
at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5564)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1054)
at android.view.Choreographer.doCallbacks(Choreographer.java:877)
at android.view.Choreographer.doFrame(Choreographer.java:807)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1039)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7615)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
Non-fatal Exception: androidx.fragment.app.strictmode.FragmentReuseViolation: Attempting to reuse fragment EffectsScreenFragment{e9f23e4} (b74813a6-11c9-4f9c-807c-47d5095919eb tag=f0) with previous ID 6a08d652-13f3-4522-b52c-14bd7064feb9
at androidx.fragment.app.strictmode.FragmentStrictMode.onFragmentReuse(FragmentStrictMode.java:296)
at androidx.fragment.app.FragmentTransaction.doAddOp(FragmentTransaction.java:299)
at androidx.fragment.app.BackStackRecord.doAddOp(BackStackRecord.java:195)
at androidx.fragment.app.FragmentTransaction.add(FragmentTransaction.java:224)
at androidx.viewpager2.adapter.FragmentStateAdapter.placeFragmentInViewHolder(FragmentStateAdapter.java:351)
at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:284)
at androidx.viewpager2.adapter.FragmentStateAdapter.onViewAttachedToWindow(FragmentStateAdapter.java:72)
at androidx.recyclerview.widget.RecyclerView.dispatchChildAttached(RecyclerView.java:7867)
at androidx.recyclerview.widget.RecyclerView$5.addView(RecyclerView.java:893)
at androidx.recyclerview.widget.ChildHelper.addView(ChildHelper.java:107)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.addViewInt(RecyclerView.java:8902)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.addView(RecyclerView.java:8860)
at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1647)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1591)
at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1395)
at androidx.recyclerview.widget.LinearLayoutManager.scrollHorizontallyBy(LinearLayoutManager.java:1124)
at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1969)
at androidx.recyclerview.widget.RecyclerView$SmoothScroller.onAnimation(RecyclerView.java:12316)
at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5564)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1054)
at android.view.Choreographer.doCallbacks(Choreographer.java:877)
at android.view.Choreographer.doFrame(Choreographer.java:807)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1039)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7615)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:964)
From the looks of these, it looks like these happened back to back (in the same second, at the very least, if not just one frame apart from each other).
Description
Component used: ViewPager2
Version used: ViewPager2 1.1.0-alpha01, Fragment 1.4.0-alpha03
Devices/Android versions reproduced on: LGE LM-X525 running Android 10
My app, Muzei uses a one screen . I am using the "Fragment StrictMode" feature introduced in Fragment to detect Fragment reuse (i.e., adding a Fragment instance that was previous removed from the
ViewPager2
with just two tabs on just1.4.0-alpha01
FragmentManager
) and hooked that up to non-fatal crash reporting. I got two reports from one device that this was being violated by ViewPager2:From the looks of these, it looks like these happened back to back (in the same second, at the very least, if not just one frame apart from each other).
I cannot seem to reproduce this myself.