Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6589] Android: Modules: runOnUiThread needs to be supported

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionWon't Fix
Resolution Date2011-12-13T13:07:16.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sSprint 2011-50
ComponentsAndroid
Labelsbranch-v8
ReporterJeff English
AssigneeOpie Cyrus
Created2011-12-12T16:54:58.000+0000
Updated2017-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

Comments

  1. Marshall Culpepper 2011-12-12

    We need to support runOnUiThread for the following annotations: * @Kroll.method * @Kroll.getProperty * @Kroll.setProperty FWIW, The original behavior was also blocking.
  2. Opie Cyrus 2011-12-13

    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.
  3. Lee Morris 2017-03-22

    Closing ticket as the issue will not fix and with reference to the above comments.

JSON Source