Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26641] iOS: On main thread openWindow and closeWindow in sequence from NavigationWindow is not working properly

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-12-19T12:36:44.000+0000
Affected Version/sRelease 7.5.0
Fix Version/sRelease 8.0.0
ComponentsiOS
Labelsrun-on-main-thread
ReporterShuo Liang
AssigneeVijay Singh
Created2018-12-10T14:44:45.000+0000
Updated2018-12-19T17:17:13.000+0000

Description

Step to reproduce issue:

1. Create a classic mobile app project. 2. Replace app.js code with the provided sample code. 3. Make sure set “run-on-main-thread” property to “true” as default 4. Run on iOS device.

Actual behaviour:

On click of “Open Yellow Window and Close Blue Window” button, “Yellow Window” is getting opened and closed immediately , if we set “run-on-main-thread” property to “true”.

Expected behaviour:

On click of “Open Yellow Window and Close Blue Window” button, it should open “Yellow Window” and close the “Blue Window”.

NOTE:

If we set “run-on-main-thread” property to “false”, then it is working as expected.

Attachments

FileDateSize
app.js2018-12-10T14:44:23.000+0000852
updated_app.js2018-12-13T06:40:50.000+00001859

Comments

  1. Vijay Singh 2018-12-11

    A quick workaround for this issue is first call closeWindow then call openWindow. Updated app.js which will work-
       function getNavWindow(){
       var win2 = Ti.UI.createWindow({
           backgroundColor: 'red',
           title: 'Red Window'
       });
       
       var win1 = Ti.UI.iOS.createNavigationWindow({
          window: win2
       });
       
       var win3 = Ti.UI.createWindow({
           backgroundColor: 'blue',
           title: 'Blue Window'
       });
       
       var win4 = Ti.UI.createWindow({
           backgroundColor: 'yellow',
           title: 'Yellow Window'
       });
       
       var button = Ti.UI.createButton({
           title: 'Open Blue Window'
       });
       button.addEventListener('click', function(){
           win1.openWindow(win3, {animated:true});
       });
       
       win2.add(button);
       var button2 = Ti.UI.createButton({
           color : 'white',
           title: 'Open Yellow Window and Close Blue Window'
       });
       button2.addEventListener('click', function(){
           win1.closeWindow(win3, {animated:false});
           win1.openWindow(win4, {animated:true});
       });
       
       win3.add(button2);
       return win1;
       }
       getNavWindow().open();
       
  2. Vijay Singh 2018-12-11

    We will look in this to fix properly.
  3. Vijay Singh 2018-12-13

    PR - https://github.com/appcelerator/titanium_mobile/pull/10535 Test Case -
       function getNavWindow(){
       var win2 = Ti.UI.createWindow({
           backgroundColor: 'red',
           title: 'Red Window'
       });
       
       var win1 = Ti.UI.iOS.createNavigationWindow({
          window: win2
       });
       
       var win3 = Ti.UI.createWindow({
           backgroundColor: 'blue',
           title: 'Blue Window'
       });
       
       var win4 = Ti.UI.createWindow({
           backgroundColor: 'yellow',
           title: 'Yellow Window'
       });
       
       var button = Ti.UI.createButton({
           title: 'Open Blue Window'
       });
       button.addEventListener('click', function(){
           win1.openWindow(win3, {animated:true});
       });
       
       win2.add(button);
       var button2 = Ti.UI.createButton({
           color : 'white',
           title: 'Open Yellow Window and Close Blue Window'
       });
       button2.addEventListener('click', function(){
           win1.openWindow(win4, {animated:true});
           win1.closeWindow(win3, {animated:false});
       });
       
       win3.add(button2);
       return win1;
       }
       getNavWindow().open();
       
  4. Shuo Liang 2018-12-13

    Customer's specific scenario is more complex then example code, where they need to close multiple previously opened windows on open of new window, So provide a new test code in updated_app.js. Hopefully the PR can cover this fix.
  5. Lokesh Choudhary 2018-12-15

    [~vijaysingh], With the updated_app.js I see that when I click Open Yellow Window and Close Blue Window I see the middle window open & then the yellow window IS this expected ?
  6. Vijay Singh 2018-12-17

    [~lchoudhary] This PR doesn't completely fix the issue. I am still working on this. Thanks!
  7. Vijay Singh 2018-12-17

    [~lchoudhary] PR updated. With the updated_app.js when you click "Open Yellow Window and Close Blue Window", middle window will open & then the yellow window (Reason is first blue window is closed with default animation (true), then yellow window is open with animation true). After you go back, it will show Middle Window. Go back again, it will show Red Window.
  8. Lokesh Choudhary 2018-12-18

    FR Passed. Waiting for merge to be enabled.
  9. Keerthi Mahalingam 2018-12-19

    Verified the fix on SDK 8.0.0.v20181219075358 .
       Test Environment:
       Operating System
         Name                        = Mac OS X
         Version                     = 10.13.6
         Architecture                = 64bit
         Memory                      = 17179869184
       Node.js
         Node.js Version             = 8.12.0
         npm Version                 = 6.4.1
       Titanium CLI
         CLI Version                 = 5.1.1
       Titanium SDK
         SDK Version                 = 8.0.0.v20181219075358
       Device              =iPhone 6s iOS 12
       Simulator        =iphone 7 iOS 11
       

JSON Source