Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5296] iOS: app pause event is fired after the os has taken a snapshot of the app

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Fix
Resolution Date2011-09-21T12:45:19.000+0000
Affected Version/sRelease 1.7.2
Fix Version/sSprint 2011-37
ComponentsiOS
Labelsn/a
ReporterJon Alter
AssigneeReggie Seagraves
Created2011-09-16T16:35:54.000+0000
Updated2017-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";
});

Associated Helpdesk Ticket

http://appc.me/c/APP-822958

Comments

  1. Jon Alter 2011-09-21

    Workaround

       // by Blain Hamon
       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() {
       // this will delete the Snapshots folder and create a file in its place 
       // so that the folder cannot be recreated
         var snapFolder = Ti.Filesystem.getFile(Ti.Filesystem.applicationSupportDirectory,"../Caches/Snapshots");
         snapFolder.deleteDirectory(true);
         snapFolder.write("No Folder for you!");
         label.text = "App has been paused";
       });
       
       Titanium.App.addEventListener('resume', function(e) {
         label.text = "App has resumed";
       });
       
  2. Neeraj Gupta 2012-06-10

    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.
  3. Lee Morris 2017-03-22

    Closing ticket as "Won't Fix".

JSON Source