[TIMOB-25750] iOS: Closing window with webview from within load event crashes app
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | n/a |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | Release 7.0.1, Release 8.0.0 |
| Fix Version/s | n/a |
| Components | n/a |
| Labels | engSchedule, ios, webview |
| Reporter | Michiel van Eerd |
| Assignee | Shak Hossain |
| Created | 2018-01-02T11:00:25.000+0000 |
| Updated | 2019-04-23T21:56:12.000+0000 |
Description
When I close a window with a webview from within the load event the app crashes. I'm not sure this is a bug. A simple workaround is to close the with a timeout of 0 seconds.
$.webView.addEventListener("load", onWebViewLoad);
// This crashes
function onWebViewLoad(e) {
$.webWindow.close();
}
// This works
function onWebViewLoad(e) {
setTimeout(function() {
$.webWindow.close();
}, 0);
}
Hello [~michielve], Tested the issue with the sample code below and unable to reproduce this on on our end using SDK SDK 7.0.1.GA. The project is running without any crash. *Test code:* *index.js*
*index.xml*$.win.open(); $.webView.addEventListener("load", onWebViewLoad); // This crashes function onWebViewLoad(e) { $.win.close(); } /* // This works function onWebViewLoad(e) { setTimeout(function() { $.webWindow.close(); }, 0); } */*Test environment:*<Alloy> <Window id="win" modal="true"> <WebView id="webView" url="http://www.appcelerator.com" /> </Window> </Alloy>*Test Result:* *Console logs:*Appcelerator Command-Line Interface, version 7.0.1 Copyright (c) 2014-2018, Appcelerator, Inc. All Rights Reserved. Operating System Name = Mac OS X Version = 10.13.1 Architecture = 64bit # CPUs = 4 Memory = 8.0GB Node.js Node.js Version = 8.9.1 npm Version = 5.5.1 Appcelerator CLI Installer = 4.2.11 Core Package = 7.0.1 Titanium CLI CLI Version = 5.0.14 node-appc Version = 0.2.41 Titanium SDKs 7.0.1.GA Version = 7.0.1 platform=iOS SimulatorCan you please try the sample code above and share the logs here?Tested it as well (env: 7.0.1, both kroll- and main-thread) and it works fine:
I agree with [~shossain], we either need a full trace-log of the crash or something with your scope is incorrect, causing this crash. I've seen those crashes when you have global Ti.App listeners in a sub-scope like event-listeners. Please check your code!var win = Ti.UI.createWindow({ backgroundColor: 'green', title: 'Window 1' }); var btn = Ti.UI.createButton({ title: 'Open Window' }); btn.addEventListener('click', openWindow); win.add(btn); var nav = Ti.UI.iOS.createNavigationWindow({ window: win }); nav.open(); function openWindow() { var win2 = Ti.UI.createWindow({ backgroundColor: 'blue', title: 'Window 2' }); var webView = Ti.UI.createWebView({ url: 'http://appcelerator.com' }); webView.addEventListener("load", function() { win2.close(); }); win2.add(webView); nav.openWindow(win2); }Thank you for your feedback. I created a new empty project without any dependencies with the same result. Immediately closing the window crashes the app, with a setTimeout 0 everything is okay. I see no log in the console after the crash, but in the system.log file is see the following: {noformat} Jan 4 09:02:01 Mac-mini-van-Michiel WebviewTest[5202]: objc[5202]: Class MPExportableArtworkProperties is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/MediaPlayer.framework/MediaPlayer (0x10b9e97d0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/MediaPlaybackCore.framework/MediaPlaybackCore (0x12cccb108). One of the two will be used. Which one is undefined. Jan 4 09:02:02 Mac-mini-van-Michiel com.apple.CoreSimulator.SimDevice.13F4A5B8-3342-4E04-BA4D-8D5506B487FD[5076] (UIKitApplication:nl.michielve.webviewtest[0x8b14][5102][5202]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0] {noformat} The Alloy project:
function doClick(e) { var win = Alloy.createController("webWindow").getView(); win.open(); } $.index.open();<Alloy> <Window class="container"> <Label id="label" onClick="doClick">Hello, World</Label> </Window> </Alloy>$.webView.addEventListener("load", function() { $.webWindow.close(); });<Alloy> <Window class="container"> <WebView id="webView" url="http://appcelerator.com" /> </Window> </Alloy>Thanks, we'll check. The logs are system-logs from iOS and unrelated. They started appearing with Xcode 8 (both Titanium and native) and can be pretty misleading. We'll come back to you later.
Hello [~hknoechel], [~michielve], I was able to reproduce the issue in iOS simulator 11.2. I ran the project with trace log. When I click on the "hello world" I do see the Appcelerator website open and in 2 seconds the app crashes to simulator home screen. No crash log in the console. My environment
Thanks.Reproducable with : iOS simulator 12.2 Node.js Node.js Version = 8.11.3 npm Version = 6.7.0 Titanium CLI CLI Version = 5.1.1 Titanium SDK SDK Version = 8.0.0.GA