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

Crash report "ava.lang.IllegalArgumentException: The view given to waitForMeasure is not attached to the window and does not have a ViewTreeObserver." #628

Closed
K1rakishou opened this issue Feb 11, 2020 · 7 comments
Labels
bug Something isn't working report/crash report Report made via the in-app reporter (auto or manual)

Comments

@K1rakishou
Copy link

UUID: 966024fbcd88b8fe742808a1229934d4
Build flavor: stable
Version name: v4.11.0
OS info: Android 9, sdk version: 28
Report description: No title
Logs:

Called from unhandled exception handler.
java.lang.IllegalArgumentException: The view given to waitForMeasure is not attached to the window and does not have a ViewTreeObserver.
	at com.github.adamantcheese.chan.utils.AndroidUtils.waitForMeasure(AndroidUtils.java:297)
	at com.github.adamantcheese.chan.ui.cell.PostCell.bindPost(PostCell.java:568)
	at com.github.adamantcheese.chan.ui.cell.PostCell.setPost(PostCell.java:304)
	at com.github.adamantcheese.chan.ui.adapter.PostAdapter.onBindViewHolder(PostAdapter.java:131)
	at androidx.recyclerview.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:7065)
	at androidx.recyclerview.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:7107)
	at androidx.recyclerview.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:6012)
	at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6279)
	at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
	at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
	at androidx.recyclerview.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2303)
	at androidx.recyclerview.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1627)
	at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1587)
	at androidx.recyclerview.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:665)
	at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
	at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
	at androidx.recyclerview.widget.RecyclerView.onLayout(RecyclerView.java:4404)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at androidx.coordinatorlayout.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1213)
	at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:899)
	at androidx.coordinatorlayout.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:919)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at androidx.swiperefreshlayout.widget.SwipeRefreshLayout.onLayout(SwipeRefreshLayout.java:625)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at androidx.drawerlayout.widget.DrawerLayout.onLayout(DrawerLayout.java:1231)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1812)
	at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1656)
	at android.widget.LinearLayout.onLayout(LinearLayout.java:1565)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.widget.FrameLayout.layoutChildren(FrameLayout.java:323)
	at android.widget.FrameLayout.onLayout(FrameLayout.java:261)
	at com.android.internal.policy.DecorView.onLayout(DecorView.java:753)
	at android.view.View.layout(View.java:20672)
	at android.view.ViewGroup.layout(ViewGroup.java:6194)
	at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2792)
	at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2319)
	at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
	at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183)
	at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
	at android.view.Choreographer.doCallbacks(Choreographer.java:761)
	at android.view.Choreographer.doFrame(Choreographer.java:696)
	at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6669)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
@K1rakishou K1rakishou added bug Something isn't working report/crash report Report made via the in-app reporter (auto or manual) labels Feb 11, 2020
@Adamantcheese
Copy link
Owner

Uhh, I'm going to close this because the logs make no sense at all. waitForMeasure is only used in two places, and neither of them are in PostCell. This is probably the only thing I noticed.

@K1rakishou
Copy link
Author

waitForMeasure is only used in two places, and neither of them are in PostCell

That's funny.

@K1rakishou
Copy link
Author

K1rakishou commented Feb 11, 2020

Maybe we could just add a check in waitForMeasure() whether a view has a parent and/or isAttachedToWindow is true? Because returning a new view in such case is kinda strange to me. Like, do we really want to do that?

@Adamantcheese
Copy link
Owner

It's just to make sure you have something to check what sort of view it is that isn't null. It's basically a null view because it isn't attached to anything, but won't throw as many errors.

@K1rakishou
Copy link
Author

K1rakishou commented Feb 12, 2020

Another report with the same thing. It was in a version with this fix, so the fix didn't help. I suggest we try checking whether the view has a parent and is attached to a window.

if (view.getParent() != null && view.isAttachedToWindow()) { ... }
UUID: 5517891af408ff2c63e265e469538099
Build flavor: dev
Version name: v4.11.0-ada6d75
OS info: Android 9, sdk version: 28
Report description: No title
Logs:
Called from unhandled exception handler.
java.lang.IllegalArgumentException: The view given to waitForLayout is not attached to the window and does not have a ViewTreeObserver.
	at com.github.adamantcheese.chan.utils.AndroidUtils.waitForLayout(AndroidUtils.java:311)
	at com.github.adamantcheese.chan.ui.layout.ThreadListLayout.scrollTo(ThreadListLayout.java:606)
	at com.github.adamantcheese.chan.ui.layout.ThreadLayout.scrollTo(ThreadLayout.java:430)
	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.scrollTo(ThreadPresenter.java:730)
	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.scrollToPost(ThreadPresenter.java:765)
	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.onChanLoaderData(ThreadPresenter.java:596)
	at com.github.adamantcheese.chan.core.site.loader.ChanThreadLoader.quickLoad(ChanThreadLoader.java:279)
	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.requestInitialData(ThreadPresenter.java:307)
	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.loadThreadInternal(ViewThreadController.java:512)
	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.loadThread(ViewThreadController.java:489)
	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.loadThread(ViewThreadController.java:578)
	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.onCreate(ViewThreadController.java:145)
	at com.github.adamantcheese.chan.controller.Controller.addChildController(Controller.java:139)
	at com.github.adamantcheese.chan.controller.NavigationController.transition(NavigationController.java:128)
	at com.github.adamantcheese.chan.ui.controller.ToolbarNavigationController.transition(ToolbarNavigationController.java:49)
	at com.github.adamantcheese.chan.ui.controller.StyledToolbarNavigationController.transition(StyledToolbarNavigationController.java:62)
	at com.github.adamantcheese.chan.controller.NavigationController.pushController(NavigationController.java:54)
	at com.github.adamantcheese.chan.ui.controller.StyledToolbarNavigationController.pushController(StyledToolbarNavigationController.java:57)
	at com.github.adamantcheese.chan.controller.NavigationController.pushController(NavigationController.java:42)
	at com.github.adamantcheese.chan.ui.controller.BrowseController.showThread(BrowseController.java:504)
	at com.github.adamantcheese.chan.ui.controller.BrowseController.showThread(BrowseController.java:435)
	at com.github.adamantcheese.chan.ui.controller.BrowseController.openPin(BrowseController.java:430)
	at com.github.adamantcheese.chan.ui.controller.DrawerController.onPinClicked(DrawerController.java:179)
	at com.github.adamantcheese.chan.ui.adapter.DrawerAdapter$PinViewHolder.lambda$new$1$DrawerAdapter$PinViewHolder(DrawerAdapter.java:467)
	at com.github.adamantcheese.chan.ui.adapter.-$$Lambda$DrawerAdapter$PinViewHolder$ZepHeJceQCn_1bmg46jOCkK6gdg.onClick(Unknown Source:2)
	at android.view.View.performClick(View.java:6610)
	at android.view.View.performClickInternal(View.java:6583)
	at android.view.View.access$3100(View.java:780)
	at android.view.View$PerformClick.run(View.java:26076)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6702)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)

@Adamantcheese Adamantcheese reopened this Feb 12, 2020
@K1rakishou
Copy link
Author

K1rakishou commented Feb 15, 2020

Gonna copy everything from a similar issue here.

E/Kuroba-dev | UNCAUGHT: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.github.adamantcheese.chan.dev/com.github.adamantcheese.chan.StartActivity}: java.lang.IllegalArgumentException: The view given to waitForLayout is not attached to the window and does not have a ViewTreeObserver.
E/Kuroba-dev | UNCAUGHT: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2944)
E/Kuroba-dev | UNCAUGHT: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3079)
E/Kuroba-dev | UNCAUGHT: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
E/Kuroba-dev | UNCAUGHT: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
E/Kuroba-dev | UNCAUGHT: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
E/Kuroba-dev | UNCAUGHT: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1836)
E/Kuroba-dev | UNCAUGHT: 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/Kuroba-dev | UNCAUGHT: 	at android.os.Looper.loop(Looper.java:193)
E/Kuroba-dev | UNCAUGHT: 	at android.app.ActivityThread.main(ActivityThread.java:6702)
E/Kuroba-dev | UNCAUGHT: 	at java.lang.reflect.Method.invoke(Native Method)
E/Kuroba-dev | UNCAUGHT: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/Kuroba-dev | UNCAUGHT: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:911)
E/Kuroba-dev | UNCAUGHT: Caused by: java.lang.IllegalArgumentException: The view given to waitForLayout is not attached to the window and does not have a ViewTreeObserver.
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.utils.AndroidUtils.waitForLayout(AndroidUtils.java:318)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.layout.ThreadListLayout.scrollTo(ThreadListLayout.java:606)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.layout.ThreadLayout.scrollTo(ThreadLayout.java:430)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.scrollTo(ThreadPresenter.java:733)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.scrollToPost(ThreadPresenter.java:768)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.onChanLoaderData(ThreadPresenter.java:599)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.core.site.loader.ChanThreadLoader.quickLoad(ChanThreadLoader.java:280)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.core.presenter.ThreadPresenter.requestInitialData(ThreadPresenter.java:310)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.loadThreadInternal(ViewThreadController.java:515)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.loadThread(ViewThreadController.java:492)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.loadThread(ViewThreadController.java:581)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.ViewThreadController.onCreate(ViewThreadController.java:145)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.controller.Controller.addChildController(Controller.java:139)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.controller.NavigationController.transition(NavigationController.java:128)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.ToolbarNavigationController.transition(ToolbarNavigationController.java:49)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.StyledToolbarNavigationController.transition(StyledToolbarNavigationController.java:62)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.controller.NavigationController.pushController(NavigationController.java:54)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.StyledToolbarNavigationController.pushController(StyledToolbarNavigationController.java:57)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.controller.NavigationController.pushController(NavigationController.java:42)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.BrowseController.showThread(BrowseController.java:504)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.StartActivity.restoreFromUrl(StartActivity.java:203)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.StartActivity.setupFromStateOrFreshLaunch(StartActivity.java:170)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.StartActivity.onCreate(StartActivity.java:157)
E/Kuroba-dev | UNCAUGHT: 	at android.app.Activity.performCreate(Activity.java:7136)
E/Kuroba-dev | UNCAUGHT: 	at android.app.Activity.performCreate(Activity.java:7127)
E/Kuroba-dev | UNCAUGHT: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
E/Kuroba-dev | UNCAUGHT: 	at android.app.ActivityThread.performLaunchActiv

Here is the culprit (found thanks to the logs sent alongside the stacktrace):

D/Kuroba-dev | WatchManager: Setting interval type from FOREGROUND to BACKGROUND

Probably should add the background/foreground check around any dialog window/popup window/toast/snackbar etc.

Or even better create custom classes that extend dialog window/popup window/toast/snackbar etc. with this check internal so it's more clean and we won't have to think about it in the future.

@K1rakishou
Copy link
Author

Still keeps happening:

E/Kuroba-dev | UNCAUGHT: Called from unhandled exception handler.
E/Kuroba-dev | UNCAUGHT: java.lang.IllegalArgumentException: The view given to waitForMeasure is not attached to the window and does not have a ViewTreeObserver.
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.utils.AndroidUtils.waitForMeasure(AndroidUtils.java:304)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.view.MultiImageView.setMode(MultiImageView.java:173)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.adapter.ImageViewerAdapter.setMode(ImageViewerAdapter.java:92)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.controller.ImageViewerController.setImageMode(ImageViewerController.java:410)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.core.presenter.ImageViewerPresenter.onTap(ImageViewerPresenter.java:490)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.view.MultiImageView.onTap(MultiImageView.java:249)
E/Kuroba-dev | UNCAUGHT: 	at com.github.adamantcheese.chan.ui.view.MultiImageViewGestureDetector.onSingleTapConfirmed(MultiImageViewGestureDetector.kt:38)
E/Kuroba-dev | UNCAUGHT: 	at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:300)
E/Kuroba-dev | UNCAUGHT: 	at android.os.Handler.dispatchMessage(Handler.java:106)
E/Kuroba-dev | UNCAUGHT: 	at android.os.Looper.loop(Looper.java:193)
E/Kuroba-dev | UNCAUGHT: 	at android.app.ActivityThread.main(ActivityThread.java:6718)
E/Kuroba-dev | UNCAUGHT: 	at java.lang.reflect.Method.invoke(Native Method)
E/Kuroba-dev | UNCAUGHT: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:491)
E/Kuroba-dev | UNCAUGHT: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Adamantcheese added a commit that referenced this issue Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working report/crash report Report made via the in-app reporter (auto or manual)
Projects
None yet
Development

No branches or pull requests

2 participants