Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-26047] iOS: Opening camera on iPhone X shows splash screen after permissions accepted

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2018-06-30T12:07:52.000+0000
Affected Version/sRelease 6.3.0, Release 7.1.1
Fix Version/sRelease 7.5.0
ComponentsiOS
LabelsforceSplashAsScreenshot, ios, storyboard
ReporterJoshua A. Ceaser
AssigneeHans Knöchel
Created2018-05-16T03:50:35.000+0000
Updated2018-10-01T22:46:47.000+0000

Description

When opening requesting permissions to open the camera on an iPhone X if the forceSplashAsSnapshot is set to true the splash screen will display instead of the camera and the application has to be killed. Steps to reproduce: 1. Create a sample application 2. Update the index.js with the attached 3. Update the alloy.js with the attached 4. Update the tiapp.xml with the NSCameraUsageDescription key in the attached tiapp.xml 5. Run the application and click on "Hello World" 6. Accept permissions 7. Notice camera loads, but then default splash screen is displayed over the camera. Example:

var win = Ti.UI.createWindow({
    backgroundColor: '#fff'
});

function doClick(e) {
	var _cameraSettings = {
		saveToPhotoGallery : false,
		showControls : true,
		allowEditing : false,
		mediaTypes : [Ti.Media.MEDIA_TYPE_PHOTO]
	};

	if (Ti.Media.hasCameraPermissions()) {
		//we have permissions, open the camera
		Ti.Media.showCamera(_cameraSettings);
	} else {
		//must request camera access
		Ti.Media.requestCameraPermissions(function(_evt) {
			if (_evt.success) {
				//permissions were granted, open camera
				Ti.Media.showCamera(_cameraSettings);
			} else {
				alert('We need camera permissions');
			}
		});
	}
}


var btn = Ti.UI.createButton({
    title: 'Trigger'
});

btn.addEventListener('click', doClick);

win.add(btn);

win.open();
tiapp.xml:
...
   <key>NSCameraUsageDescription</key>
  <string>To allow you to take photos of documents for uploading</string>
...

Comments

  1. Hans Knöchel 2018-05-16

    The issue is valid! Although the splash screen disappears when closing the camera again on my iPhone X test device. I will debug it this week and give an update afterwards. EDIT: Also, I think this should not be specific to the camera and the iPhone X but in general using storyboards + the forceSplashScreen + system dialogs (including all permission dialogs, low battery warning etc). Can you confirm that? I am not sure if this is even fixable, since system alert cannot really be controlled properly. EDIT 2: Found a fix, pushing now.
  2. Hans Knöchel 2018-05-16

    PR: https://github.com/appcelerator/titanium_mobile/pull/10054 Test-case: Above [~jceaser] You can patch your SDK today by replacing the references in the linked pull request locally. Thanks for raising this!
  3. Joshua A. Ceaser 2018-05-16

    How do I apply a patch to my SDK, I've never done that?
  4. Hans Knöchel 2018-05-16

    I just described that. For details, please reach out to the community via TiSlack or StackOverflow. This channel is only for bug reports, no general Titanium questions.
  5. Joshua A. Ceaser 2018-05-24

    Can this be applied to any version of the SDK or only the latest GA eg. 7.1.1.GA? I ask because I received an error when applying it to 6.3.0.GA.
  6. Hans Knöchel 2018-06-30

    [~jceaser] It should be applied to 7.x at least, since there were other changes between 6 and 7 regarding that class. You can also try it out on master, since the PR was just integrated into the SDK.
  7. Raef Akehurst 2018-08-29

    I had an issue where the camera was occasionally crashing with an "unknown" error when the app was paused with the camera open and then resumed from the background. Through dumb luck (and a lot of trial-and-error testing) I discovered that when I set Ti.App.forceSplashAsSnapshot to "false", the error did not occur (I, obviously, previously had it set to "true"). To get around this, I simply set Ti.App.forceSplashAsSnapshot to "false" when opening the camera and "true" when hiding it. My crash is gone. It sounds like it might be the same issue as listed here, and therefore I am posting this in the hope that it might save someone from pulling out their hair for hours as I have just done!
  8. Hans Knöchel 2018-08-30

    Hey [~raefa], thanks for the feedback! This issue has been resolved and fixed for 7.5.0 (current master), did you try that version already? In any case, it sounds like a good workaround for current versions of the SDK, so again, thank you!
  9. Raef Akehurst 2018-08-31

    Hi [~hknoechel]. I just tried the 7.5.0 nightly build and it indeed seems to have fixed the issue I reported. Good stuff!
  10. Keerthi Mahalingam 2018-10-01

    Verified the fix on SDK 7.5.0.v20181001073642. Camera loads fine and no splash screen after permission accepted. Works fine. Closing.
        Name                        = Mac OS X
          Version                     = 10.13.6
          Architecture                = 64bit
        Node.js
          Node.js Version             = 8.9.1
          npm Version                 = 5.5.1
        Titanium CLI
          CLI Version                 = 5.1.1
        Titanium SDK
        SDK                              =7.5.0.v20181001073642
        Device                         =iPhone X iOS 11,Iphone 6s iOS 12
        

JSON Source