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

CalledFromWrongThreadException #1346

Closed
tianxiaogu opened this Issue Jul 6, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@tianxiaogu

tianxiaogu commented Jul 6, 2018

v3.2.2 from F-Droid

This should be a trivial bug. GUI should not be updated from a background thread.

android.view.ViewRootImpl$CalledFromWrongThreadException
	at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6556)
	at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:907)
	at android.view.View.requestLayout(View.java:18728)
	at android.view.View.requestLayout(View.java:18728)
	at android.view.View.requestLayout(View.java:18728)
	at android.view.View.requestLayout(View.java:18728)
	at android.view.View.requestLayout(View.java:18728)
	at android.view.View.requestLayout(View.java:18728)
	at android.support.v4.widget.DrawerLayout.requestLayout(DrawerLayout.java:1265)
	at android.view.View.requestLayout(View.java:18728)
	at android.widget.RelativeLayout.requestLayout(RelativeLayout.java:360)
	at android.view.View.requestLayout(View.java:18728)
	at android.widget.AbsListView.requestLayout(AbsListView.java:1975)
	at android.widget.ListView.setAdapter(ListView.java:519)
	at com.amaze.filemanager.activities.MainActivity.refreshDrawer(MainActivity.java:1519)
	at com.amaze.filemanager.activities.MainActivity.onBookAdded(MainActivity.java:2188)
	at com.amaze.filemanager.utils.DataUtils$1.run(DataUtils.java:210)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:148)
	at android.os.HandlerThread.run(HandlerThread.java:61)
@VishalNehra

This comment has been minimized.

Member

VishalNehra commented Jul 6, 2018

More details please. What operation were you trying to perform?
Just checked with the code, this shouldn't be a problem in current master or v.3.3.0

@EmmanuelMess

This comment has been minimized.

Member

EmmanuelMess commented Jul 6, 2018

v3.2.2 is in neither. Problem is here.

@tianxiaogu

This comment has been minimized.

tianxiaogu commented Jul 6, 2018

Thanks for your reply! We found this crash via our automated testing tool. Since it seems to relate to some concurrent/asynchronous tasks, we cannot manage to reproduce it with steps we recorded.

By analyzing the source code in the master branch, MainActivity implements the interface DataChangeListener. DataUtils has a call to onBookAdded. If AppConfig.runInBackground starts another thread, the GUI may be updated in that thread.

AppConfig.runInBackground(() -> dataChangeListener.onBookAdded(i, true));

@VishalNehra

This comment has been minimized.

Member

VishalNehra commented Jul 6, 2018

Checked with the code, nice catch; this should be fixed.

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