[TIMOB-6589] Android: Modules: runOnUiThread needs to be supported
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2011-12-13T13:07:16.000+0000 |
Affected Version/s | Release 1.8.0.1 |
Fix Version/s | Sprint 2011-50 |
Components | Android |
Labels | branch-v8 |
Reporter | Jeff English |
Assignee | Opie Cyrus |
Created | 2011-12-12T16:54:58.000+0000 |
Updated | 2017-03-22T17:48:39.000+0000 |
Description
Specifying "@Kroll.setProperty(runOnUiThread = true)" has no effect on the thread that the method is executed. This is exhibited in the StyledLabel and Gigya modules. The StyledLabel module sets a property during an event notification from a button click. When the property is updated it makes a call to refresh the display of the label. Since the execution thread is different than the thread that created the view a CalledFromWrongThreadExeption is thrown. The label, in this case, was created on the main thread but the property update and subsequent attempt to update the view is running on the Kroll runtime thread.
12-12 16:38:39.466: ERROR/RhinoObject(544): (KrollRuntimeThread) [119,93332] Only the original thread that created a view hierarchy can touch its views.
12-12 16:38:39.466: ERROR/RhinoObject(544): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
To duplicate this issue,
1. Build the StyedLabel module from the apilevel2 branch of my module fork.
2. Run the example application from the module. The styled label will display correctly.
3. Click on the "Only allow links" button -- this will force an update of the property that attempts to update the styled label view
We need to support runOnUiThread for the following annotations: *
@Kroll.method
*@Kroll.getProperty
*@Kroll.setProperty
FWIW, The original behavior was also blocking.Discussed with Marshall Culpepper and Jeff English. Decided that runOnUIThread will not be added back in and instead we will require async and sync thread behavior to use the handler.callback mechanism shown in platform already. Jeff English will provide documentation and guide regarding the shift.
Closing ticket as the issue will not fix and with reference to the above comments.