[TIMOB-20041] iOS: Window close event not fired on NavigationWindow with ListView
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-03-16T09:58:09.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.2.0 |
Components | iOS |
Labels | Community, ios, mainthread, sdk-5.0.2 |
Reporter | Michiel van Eerd |
Assignee | Pedro Enrique |
Created | 2015-10-15T11:58:31.000+0000 |
Updated | 2016-03-16T09:58:09.000+0000 |
Description
When opening a new window with a ListView from within a NavigationWindow, the close event of this window sometimes get fired and sometimes won't.
Example:
<Alloy>
<NavigationWindow id="navwin" platform="ios">
<Window id="win1" title="Red Window" backgroundColor="red">
<Button id="button" onClick="openBlueWindow">Open Blue Window</Button>
</Window>
</NavigationWindow>
</Alloy>
function openBlueWindow(e) {
var win2 = Alloy.createController('win2').getView();
win2.addEventListener("close", function() {
console.log("CLOSED!");
});
$.navwin.openWindow(win2);
}
$.navwin.open();
<Alloy>
<Window id="win2" title="Blue Window" backgroundColor="blue">
<ListView id="list">
<ListSection>
<ListItem title="List item 1"></ListItem>
<ListItem title="List item 2"></ListItem>
<ListItem title="List item 3"></ListItem>
</ListSection>
</ListView>
</Window>
</Alloy>
function closeWindow(){
$.win2.close();
}
When you close window 2 the expected behaviour is to see "CLOSED!" in the console, but it only randomly shows.
Happens on iOS 9 simulator with SDK 5.0.0.GA and above. Happens on iOS 8.4 simulator on SDK 5.0.0.GA and above, so SDK 4.1.1.GA is okay on iOS 8.4.
Took me a while to figure out what went wrong, but I also have this issue, in a classic project, I prepared my testcase before I found this ticket, so I'm submitting it anyway:
For some reason my code in my above comment is indented kind of weird, but on a colleagues screen it looks fine, to be sure, I've put it here: [http://jsfiddle.net/GertjanSmits/fqkdw8pe/].
Good to hear (not for you of course) I'm not the only one as I was beginning to think I did something wrong. Strange no one else noticied this before. Hopefully someone of Appcelerator picks this one up!
I have EXACTLY the same problem!! I have it on iOS and Android on my both apps. Same problem appears everywhere, devices, emulator and it's exactly as you said, on a random way. It looks like sometimes "something" is removing the "close" event listener that I attached before and it's annoying since all application is based on that. I had never that problem before SDK 5 and I'm with Titanium since SDK 1.7
I have not experienced this on Android, but as it's random behaviour, maybe I just did not noticed it yet. I also build much of my application actions around the close event, for example do some API calls after a window is closed. So this is a VERY big bug for me too!
Same here. Lots based on that close event and YES it's s big bug for me and I don't know what to do to tweak the situation. I have a feeling it's a bug in a garbage collector or something like that because event somehow get lost :(
[~michielve] Hello , could you please try the sample code provided by Gertjan , with the newest SDK which can be found [here](http://builds.appcelerator.com.s3.amazonaws.com/index.html#5_2_X). I ran the code multiple times and the event handler for the windows close is being called. If you are still having the issue after testing with the new SDK, I will investigate this further !
Just to troubleshoot: Does this work with
<run-on-main-thread>true</run-on-main-thread>
enabled in the<ios/>
section of your tiapp.xml? It looks very suspicious to be a main-thread issue. EDIT: Created an easy-to-run example of your original alloy-demo: https://gist.github.com/hansemannn/ab83c7730999b7ea3100 Would be very interesting to see if it works with main-thread enabled (which will be default in the 5.4.0 release)I wanted to test your "run-on-main-thread" suggestion but before that, I tried to test it again (because SDK updated couple times since then). So, I noticed that somehow the problem is gone and all works fine now!!:) It looks like last update of SDK 5.2.0GA fix that issue. I tested on iOS emulator 9.2 (iPhone6S), SDK 5.2.0GA and it's working great now! Tested also on Genymotion emulator (for Android), SDK 5.2.0GA - Also works great now! Btw, in the title appears "*+iOS+*: Window close event not fired on NavigationWindow with ListView". I am sure the same problem was for Android as well. I tested it couple of times and *+Android had the same problem+*!
Thanks for the feedback [~mry], appreciate that! Android and iOS are developed independently, so that might have been another (already fixed) issue. Also note, that the
<run-on-main-thread/>
fix is not enabled by default in 5.2.0.GA. Although you can enable it and most of your code will work like a charm, it is not 100 % stable for all use-cases, yet. This will be part of the upcoming 5.4.0.GA release in a few months. We will wait for other ticket watchers to confirm that the above solution works for them and close it after that. Thanks guys!I can also confirm that the bug seems to have been fixed with version 5.2.0.GA. :) Thanks!
I can also confirm that with iOS 9.2 + SDK 5.2.0.GA this issue seems to be resolved! Many thanks! Note: I did not do anything with run-on-main-thread, so I guess the default is used for SDK 5.2.0.GA.
Reporter and watchers confirmed that the issue is fixed with latest 5.2.0.GA