Bug #1267
Updated by Soren Stoutner 8 days ago
This is an odd race condition that sometimes manifests under the following circumstances. 1. The bottom app bar is enabled. 2. The keyboard is displayed on the screen. 3. The navigation drawer is opened for the first time. The following crash is produced: <pre> 01-25 08:18:00.129 24583 24583 E AndroidRuntime: FATAL EXCEPTION: main 01-25 08:18:00.129 24583 24583 E AndroidRuntime: Process: com.stoutner.privacybrowser.alt, PID: 24583 01-25 08:18:00.129 24583 24583 E AndroidRuntime: java.lang.IllegalStateException: ViewHolder views must not be attached when created. Ensure that you are not passing 'true' to the attachToRoot parameter of LayoutInflater.inflate(..., boolean attachToRoot) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at k0.O.i(Unknown Source:930) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at k0.s.b(Unknown Source:62) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.recyclerview.widget.LinearLayoutManager.Y0(Unknown Source:0) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.recyclerview.widget.LinearLayoutManager.L0(Unknown Source:48) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.recyclerview.widget.LinearLayoutManager.c0(Unknown Source:920) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.recyclerview.widget.RecyclerView.r(Unknown Source:34) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.recyclerview.widget.RecyclerView.p(Unknown Source:42) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.recyclerview.widget.RecyclerView.onLayout(Unknown Source:7) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:270) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at androidx.drawerlayout.widget.DrawerLayout.onLayout(Unknown Source:125) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:270) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:270) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1891) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1729) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1638) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:270) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1891) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1729) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.LinearLayout.onLayout(LinearLayout.java:1638) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.layoutChildren(FrameLayout.java:332) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.widget.FrameLayout.onLayout(FrameLayout.java:270) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at com.android.internal.policy.DecorView.onLayout(DecorView.java:767) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.View.layout(View.java:25409) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewGroup.layout(ViewGroup.java:6440) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:4964) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:4113) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2977) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:10429) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1415) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1424) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.Choreographer.doCallbacks(Choreographer.java:1024) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.Choreographer.doFrame(Choreographer.java:953) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1398) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:991) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:232) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.os.Looper.loop(Looper.java:317) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8787) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:591) 01-25 08:18:00.129 24583 24583 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:871) </pre> The <code>ViewHolder</code> that is not properly initialized is the <code>NavigationView</code>, which is a <code>RecyclerView</code> generated from a <code>Menu</code> placed in a <code>DrawerLayout</code>. The crash only happens if the keyboard is displayed when the Navigation Drawer is opened for the first time, which causes the layout to be inflated. When that happens, the drawer is animated into view from the left and the keyboard, which is displayed in an inset that forces both the Navigation Drawer and the app bar up, is animated down at the same time, causing the Navigation Drawer to expand and the app bar to lower. Something about all of these things happening at the same time creates a race condition that on some devices and configurations reliably generates the above error message, but on other devices does not. Once the Navigation Drawer layout has been inflated by opening it once, it can then be closed close and reopened with the keyboard visible without causing problems.