Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6151] [Android] Run on main thread = true not firing Destroy and Stop Events

GitHub Issuen/a
TypeBug
Priorityn/a
StatusResolved
ResolutionDuplicate
Resolution Date2019-02-26T21:55:54.000+0000
Affected Version/sn/a
Fix Version/sn/a
Componentsn/a
Labels7.5.0.GA, android, run-on-main-thread
Reporterjosh.mocek
AssigneeShak Hossain
Created2019-02-26T20:46:37.000+0000
Updated2019-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

FileDateSize
alloy.js2019-02-26T20:45:19.000+00001696
app.tss2019-02-26T20:45:19.000+0000780
index.js2019-02-27T21:53:21.000+00001831
index.js2019-02-26T20:45:19.000+00002640
index.tss2019-02-26T20:45:19.000+0000155
index.xml2019-02-27T21:53:21.000+0000368
index.xml2019-02-26T20:45:19.000+0000386
tiapp.xml2019-02-26T20:45:43.000+00003863

Comments

  1. Sharif AbuDarda 2019-02-26

    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.
  2. Joshua Quick 2019-02-26

    This specific issue that [~josh.mocek] has brought up is a duplicate of [TIMOB-26850]
  3. Joshua Quick 2019-02-26

    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.
  4. Joshua Quick 2019-02-27

    [~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 for onDestroy on the last activity window, because the app is about to exit. Currently, when "run-on-main-thread" is set to true, 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 the Ti.UI.Window "open" event listener anymore, because that event gets fired after the Java onCreate(), onStart(), and onResume() 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 calling Window.open(). For example:
       var window = Ti.UI.createWindow();
       window.activity.onCreate = function() {
       	Ti.API.info("### Activity.onCreate() called.");
       };
       window.open();
       
  5. josh.mocek 2019-02-27

    Unfortunately the scanner disconnect does not call the onClose event. Here is the cleaned up file I was testing with. [^index.js] [^index.xml]

JSON Source