[AC-6151] [Android] Run on main thread = true not firing Destroy and Stop Events
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Resolved |
Resolution | Duplicate |
Resolution Date | 2019-02-26T21:55:54.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | 7.5.0.GA, android, run-on-main-thread |
Reporter | josh.mocek |
Assignee | Shak Hossain |
Created | 2019-02-26T20:46:37.000+0000 |
Updated | 2019-02-27T21:53:25.000+0000 |
Description
Build this app onto an android device. Connect a bluetooth keyboard. Open the app. Press the blue button a few times. Disconnect the scanner while the app is counting. The app resets and picks back up where it left off.
I did notice that on 7.5.0 run-on-main-thread = false when the scanner disconnects it calls:
destroy
stop
window open
start
resume
when run-on-main-thread = true it only runs:
window open
start
resume
Should it not still be running destroy and stop when run-on-main-thread = true?
Attachments
File | Date | Size |
---|---|---|
alloy.js | 2019-02-26T20:45:19.000+0000 | 1696 |
app.tss | 2019-02-26T20:45:19.000+0000 | 780 |
index.js | 2019-02-27T21:53:21.000+0000 | 1831 |
index.js | 2019-02-26T20:45:19.000+0000 | 2640 |
index.tss | 2019-02-26T20:45:19.000+0000 | 155 |
index.xml | 2019-02-27T21:53:21.000+0000 | 368 |
index.xml | 2019-02-26T20:45:19.000+0000 | 386 |
tiapp.xml | 2019-02-26T20:45:43.000+0000 | 3863 |
Hello [~josh.mocek], You were in touch with our team on the same issue in another ticket AC-5929. Please do not create a separate ticket of the same issue. Please post your comment in that ticket. Closing this. Thanks.
This specific issue that [~josh.mocek] has brought up is a duplicate of [TIMOB-26850]
This is also only an issue with the 1st activity window when backing out of the app. I recommend that you use the
Ti.UI.Window
object's "close" event instead. Especially since it work on both Android and iOS.[~josh.mocek], Admittedly there is a design issue here on Titaniums' end. Titanium's activity callbacks (
onCreate
,onStart
,onDestroy
, etc.) *+need+* to be synchronous. They need to be invoked as soon as the equivalent Java methods are invoked. Especially foronDestroy
on the last activity window, because the app is about to exit. Currently, when "run-on-main-thread" is set totrue
, they are queued to be invoked after their equivalent Java method has been called, which has a short delay. If we change these callbacks to be synchronous, then this will cause a breaking-change where you can no longer set up your callbacks from theTi.UI.Window
"open" event listener anymore, because that event gets fired after the JavaonCreate()
,onStart()
, andonResume()
methods get called on startup. But that said, there is an easy backward compatible solution to this. You would need to set up your callback before callingWindow.open()
. For example:Unfortunately the scanner disconnect does not call the onClose event. Here is the cleaned up file I was testing with. [^index.js] [^index.xml]