[TIMOB-26641] iOS: On main thread openWindow and closeWindow in sequence from NavigationWindow is not working properly
| GitHub Issue | n/a |
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2018-12-19T12:36:44.000+0000 |
| Affected Version/s | Release 7.5.0 |
| Fix Version/s | Release 8.0.0 |
| Components | iOS |
| Labels | run-on-main-thread |
| Reporter | Shuo Liang |
| Assignee | Vijay Singh |
| Created | 2018-12-10T14:44:45.000+0000 |
| Updated | 2018-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
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();We will look in this to fix properly.
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();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.
[~vijaysingh], With the
updated_app.jsI see that when I clickOpen Yellow Window and Close Blue WindowI see themiddle windowopen & then theyellow windowIS this expected ?[~lchoudhary] This PR doesn't completely fix the issue. I am still working on this. Thanks!
[~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.
FR Passed. Waiting for merge to be enabled.
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