[TIMOB-4538] iOS: WebView does not receive 'pause' event
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-03-29T01:00:34.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Sprint 2012-03, Release 2.0.0, Release 1.8.2, Sprint 2012-06 |
Components | iOS |
Labels | module_webview, parity, qe-3.2.1, qe-testadded, webview |
Reporter | tom quas |
Assignee | Stephen Tramer |
Created | 2011-06-03T23:22:53.000+0000 |
Updated | 2014-03-29T01:00:39.000+0000 |
Description
first try:
x.js
Ti.UI.createWebView({ url:'y.html' });
y.html:
Ti.App.addEventListener('pause', function() { Ti.API.log('you won't see this message'); });
upon pausing the app, the handler does not get invoked. i then tried another alternative:
x.js
Ti.UI.createWebView({ url:'y.html' });
Ti.App.addEventListener('pause', function() { Ti.API.log('ok, fire'); Ti.App.fireEvent('app.pause'); });
y.html:
Ti.App.addEventListener('app.pause', function() { Ti.API.log('you won't see this message either'); });
this time the pause event gets caught, 'app.pause' gets fired, but still the webview stays silent. somehow this leads me to the conclusion that webviews won't receive events after an app entered the 'pause' state, because other event handlers work just fine while the app is in running mode.
A complete usecase supplied by Rick Blalock:
var webview = Ti.UI.createWebView({
url: "test.html"
})
var win = Ti.UI.createWindow();
win.add(webview);
win.open();
Ti.App.addEventListener("pause", function() {
Ti.API.info("Pause event received");
Ti.App.fireEvent("appPaused");
});
Ti.App.addEventListener("appPaused", function() {
Ti.API.info("App.js received appPaused event");
});
<html>
<head>
<title></title>
<script type="text/javascript">
Ti.App.addEventListener("appPaused", function(_event) {
Ti.API.info("WebView received appPaused event");
});
</script>
</head>
<body>
</body>
</html>
Attachments
File | Date | Size |
---|---|---|
app.js | 2011-06-14T07:55:46.000+0000 | 346 |
test.html | 2011-06-14T07:55:46.000+0000 | 215 |
tried to rearrange code, but even a webview.evalJS() as the first in the pause handler won't be executed. looks like a webview gets unresponsive right away upon pause events?
Tom In order for us to progress this issue, please edit your ticket to include a proper [Use-case](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases). Also, please do the following: * use the wiki markup provided, to format the ticket correctly * include the Titanium SDK version + build date + build hash * include the iOS version tested Thank you
Attaching repro code as per customer request, outlining customer's method. Tested using 1.7.0, iOS 4.3 on June 14.
Paul, can you reproduce the issue using Matthew's code? Is there anything else I can provide?
Tom Once you have gone through the three points I have listed above, and also moved the environment information to the environment field, I will be happy to transfer this ticket to the relevant project. Note that, for such a small usecase, it would be better to have the code in the ticket, properly formatted, than in attachments. Thanks
Paul, this issue has been tagged ios, 4.3, webview; env has been declared 1.6.2, your colleague from pro support attached the code necessary to reproduce the problem, he mentioned that he can reproduce the issue w/ Ti 1.7, too. at this point i do not know what else to provide. thx
Better?
Aha. What's going on is that when the pause event's underlying notification fires, the main run loop is stopped. So any performSelectorOnMainThread won't happen until resume.
Interesting. This may prove nontrivial for web views. Even with running things on the main thread with our own override, the web view fails to process commands. When we try to jury-rig things by calling [[NSRunLoop mainRunLoop] runUntilDate:deadline] during the application shutdown sequence, it ends up calling the app shutdown sequence again, leading to an ugly infinite loop.
Closing as Fixed. SDK: 1.9.0.v20120210100134 Studio: 1.0.8.201201262211 OS: Lion Devices Tested: iPhone Simulator 5.0, iPod 4.3.3, iPad2 4.3.5, iPhone4 5.0.1
Reopening as part of PR #1597 (https://github.com/appcelerator/titanium_mobile/pull/1597) omnibus.
Combined pull #1597 + #1645
Closing bug. Verified fix on: SDK build: 2.0.0.v20120314090311 Titanium Studio, build: 2.0.0.201203132050 xcode: 4.2 Device: iphone 4s (5.0.1)
Reopening since pause event not being fired on Android. Works well on ios. Checked with ipad mini(v6.0). Reopened this bug,as does not specify any specific platform. Not a regression. Verified with: Studio: 3.1.2.201308091728 SDK: 3.1.2.v20130813151607 acs:1.0.5 alloy:1.2.0-alpha6 titanium:3.1.2-alpha titanium-code-processor:1.0.2-alpha OS: OSX 10.8.4 Device: Nexus 7(v4.2.1) Xcode:4.6.3
http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.App-event-pause Ti.App.addEventListener("pause",function()) is only supported for iOS, not Android. Closing.