Titanium JIRA Archive
Appcelerator Community (AC)

[AC-5298] Android: CalledFromWrongThreadException when accessing the action bar

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionNeeds more info
Resolution Date2017-11-07T20:17:58.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsAndroid
ReporterLuc-Edmond Gaspard
AssigneeShak Hossain
Created2017-10-20T19:13:26.000+0000
Updated2017-11-07T20:17:58.000+0000

Description

App sometimes crash when accessing the actionbar, by calling window.getActivity().actionBar. In ActionBarProxy.java, actionBar.setDisplayOptions I think it should be called on the UI thread : https://github.com/appcelerator/titanium_mobile/blob/master/android/titanium/src/java/org/appcelerator/titanium/proxy/ActionBarProxy.java#L58
10-20 15:02:13.209: W/System.err(26948): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
10-20 15:02:13.219: W/System.err(26948): 	at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:8129)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:1258)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.ViewGroup.invalidateChild(ViewGroup.java:5430)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.View.invalidateInternal(View.java:13927)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.View.invalidate(View.java:13891)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.View.invalidate(View.java:13875)
10-20 15:02:13.219: W/System.err(26948): 	at android.widget.ImageView.invalidateDrawable(ImageView.java:262)
10-20 15:02:13.219: W/System.err(26948): 	at android.graphics.drawable.Drawable.invalidateSelf(Drawable.java:844)
10-20 15:02:13.219: W/System.err(26948): 	at android.graphics.drawable.Drawable.setVisible(Drawable.java:1575)
10-20 15:02:13.219: W/System.err(26948): 	at android.widget.ImageView.onDetachedFromWindow(ImageView.java:1511)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.View.dispatchDetachedFromWindow(View.java:15846)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4952)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.ViewGroup.removeViewInternal(ViewGroup.java:4925)
10-20 15:02:13.219: W/System.err(26948): 	at android.view.ViewGroup.removeView(ViewGroup.java:4856)
10-20 15:02:13.219: W/System.err(26948): 	at android.support.v7.widget.Toolbar.setNavigationIcon(Toolbar.java:962)
10-20 15:02:13.219: W/System.err(26948): 	at android.support.v7.widget.ToolbarWidgetWrapper.updateNavigationIcon(ToolbarWidgetWrapper.java:613)
10-20 15:02:13.219: W/System.err(26948): 	at android.support.v7.widget.ToolbarWidgetWrapper.setDisplayOptions(ToolbarWidgetWrapper.java:392)
10-20 15:02:13.219: W/System.err(26948): 	at android.support.v7.app.ToolbarActionBar.setDisplayOptions(ToolbarActionBar.java:260)
10-20 15:02:13.219: W/System.err(26948): 	at android.support.v7.app.ToolbarActionBar.setDisplayOptions(ToolbarActionBar.java:254)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.titanium.proxy.ActionBarProxy.<init>(ActionBarProxy.java:58)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.titanium.proxy.ActivityProxy.getActionBar(ActivityProxy.java:258)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:62)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:921)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1144)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.titanium.proxy.TiViewProxy.handleMessage(TiViewProxy.java:363)
10-20 15:02:13.219: W/System.err(26948): 	at org.appcelerator.titanium.proxy.TiWindowProxy.handleMessage(TiWindowProxy.java:116)
10-20 15:02:13.229: W/System.err(26948): 	at ti.modules.titanium.ui.WindowProxy.handleMessage(WindowProxy.java:452)
10-20 15:02:13.229: W/System.err(26948): 	at android.os.Handler.dispatchMessage(Handler.java:98)
10-20 15:02:13.229: W/System.err(26948): 	at android.os.Looper.loop(Looper.java:158)
10-20 15:02:13.229: W/System.err(26948): 	at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:118)
10-20 15:02:13.239: E/TiExceptionHandler(26948): (main) [112,4922] ----- Titanium Javascript Runtime Error -----
10-20 15:02:13.239: E/TiExceptionHandler(26948): (main) [0,4922] - In undefined:7,39
10-20 15:02:13.239: E/TiExceptionHandler(26948): (main) [0,4922] - Message: Uncaught Only the original thread that created a view hierarchy can touch its views.

Comments

  1. Mostafizur Rahman 2017-10-26

    Hello [~gaspard.le], Can you please share a simple test case to reproduce this on our end? Thanks

JSON Source