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

Do not crash when log called on a background thread #7

Closed
wants to merge 2 commits into from
Closed

Do not crash when log called on a background thread #7

wants to merge 2 commits into from

Conversation

pchmielowski
Copy link

When DebugOverlay.with(this).log("Message"); is called on a background thread, CalledFromWrongThreadException occur with the following stack trace:

android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
                                                                                            at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:7286)
                                                                                            at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1155)
                                                                                            at android.view.View.requestLayout(View.java:21926)
                                                                                            at android.view.View.requestLayout(View.java:21926)
                                                                                            at android.widget.AbsListView.requestLayout(AbsListView.java:1998)
                                                                                            at android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.java:848)
                                                                                            at android.widget.AbsListView$AdapterDataSetObserver.onChanged(AbsListView.java:6414)
                                                                                            at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:37)
                                                                                            at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
                                                                                            at com.hannesdorfmann.debugoverlay.DebugOverlayView.addMessage(DebugOverlayView.java:90)
                                                                                            at com.hannesdorfmann.debugoverlay.DebugOverlayService.logMsg(DebugOverlayService.java:45)
                                                                                            at com.hannesdorfmann.debugoverlay.DebugOverlay$MessageDispatcher.dispatch(DebugOverlay.java:118)
                                                                                            at com.hannesdorfmann.debugoverlay.DebugOverlay$MessageDispatcher.enqueueMessage(DebugOverlay.java:101)
                                                                                            at com.hannesdorfmann.debugoverlay.DebugOverlay.log(DebugOverlay.java:54)

To reproduce it, please checkout 898d23f commit from this pull request, set Foregroung thread switch to false and press fab more than once.

Commit cf66434 fixes this issue by invoking view.addMessage(msg) on the UI thread.

@pchmielowski
Copy link
Author

@sockeqwe Any chances to merge this PR?

@sockeqwe sockeqwe closed this in ed2e81c Jan 7, 2019
@sockeqwe
Copy link
Owner

sockeqwe commented Jan 7, 2019

Sorry, @pchmielowski I somehow overlooked your PR. I have released a new version 0.4.0 with a fix for this problem (but different technical solution, therefore closed this PR).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants