[TIMOB-26047] iOS: Opening camera on iPhone X shows splash screen after permissions accepted
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-06-30T12:07:52.000+0000 |
Affected Version/s | Release 6.3.0, Release 7.1.1 |
Fix Version/s | Release 7.5.0 |
Components | iOS |
Labels | forceSplashAsScreenshot, ios, storyboard |
Reporter | Joshua A. Ceaser |
Assignee | Hans Knöchel |
Created | 2018-05-16T03:50:35.000+0000 |
Updated | 2018-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>
...
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.
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!
How do I apply a patch to my SDK, I've never done that?
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.
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.
[~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.
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 setTi.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!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!
Hi [~hknoechel]. I just tried the 7.5.0 nightly build and it indeed seems to have fixed the issue I reported. Good stuff!
Verified the fix on SDK 7.5.0.v20181001073642. Camera loads fine and no splash screen after permission accepted. Works fine. Closing.