[TIMOB-5296] iOS: app pause event is fired after the os has taken a snapshot of the app
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2011-09-21T12:45:19.000+0000 |
Affected Version/s | Release 1.7.2 |
Fix Version/s | Sprint 2011-37 |
Components | iOS |
Labels | n/a |
Reporter | Jon Alter |
Assignee | Reggie Seagraves |
Created | 2011-09-16T16:35:54.000+0000 |
Updated | 2017-03-22T21:10:30.000+0000 |
Description
When an application is backgrounded, iOS takes a screenshot of the app and uses it in its animation. This screenshot it stored on the filesystem of the device. The user wants to hide sensitive information from the screen before this screenshot is taken. When this is done in Titanium, iOS takes the screenshot before anything in the pause event listener is run. In a native app, it runs fast enough to change the label before the screenshot is taken.
Step 1: run the code below
Step 2: hit the home button
Step 3: go look at the screenshot that was taken.
(my screenshot was in "/Users/jalter/Library/Application Support/iPhone Simulator/4.3.2/Applications/4BF6EF8F-5523-421A-8FE8-6793B79CD3F3/Library/Caches/Snapshots/com.appcelerator.test3")
Step 4: we want the screenshot to say "App has been paused", but the label change does not happen fast enough.
var win = Ti.UI.createWindow({
backgroundColor : 'white',
orientationModes : [Ti.UI.PORTRAIT]
});
win.open();
var label = Ti.UI.createLabel({
text : 'No app event received. Make call while running app',
textAlign : 'center',
width : 'auto'
});
win.add(label);
Titanium.App.addEventListener('pause', function() {
label.text = "App has been paused";
});
Titanium.App.addEventListener('resume', function(e) {
label.text = "App has resumed";
});
Workaround
There is almost no way to guarantee that the UI will be updated from the JS thread in time on the pause/paused event. Titanium documentation clearly states that. The only way to implement this functionality would be in the native code itself. A simple solution would be to pop up a UIView (maybe just the splash screen with the default image) in front of everything else and obscure the app. This would kind of make sure that the snapshot taken by iOS does not have any sensitive information. The drawback is that the obscuring a view would be visible to the users momentarily when the app boots up and before we can remove it from the view heirarchy. We could drive this off of an app property (defined in tiapp.xml) or a runtime property (Ti.App.Properties.setString) so that the obscuring of data could be on a per screen basis.
Closing ticket as "Won't Fix".