以下是包含完整日誌的回報範本:
Title: WKWebView
File Upload Causes App Crash When Selecting Camera or Recording Options
Body:
Hello,
I am experiencing a critical issue with WKWebView
in our iOS app when handling file uploads. We are using the following HTML element to allow users to capture images or videos, select from their photo library, or choose a file from the file system:
<input type="file" accept="image/*;capture=camera" id="cameraInput">
Issue Description:
When a user selects the camera or recording option, the app immediately crashes and returns to the WKWebView
screen. This issue does not occur when selecting a file from the photo library or file system.
Logs: Below are the relevant logs captured when the issue occurs:
Presenting view controller <_UIContextMenuActionsOnlyViewController: 0x1034349e0> from detached view controller <MailVwCtl: 0x103838800> is not supported, and may result in incorrect safe area insets and a corrupt root presentation. Make sure <MailVwCtl: 0x103838800> is in the view controller hierarchy before presenting from it. Will become a hard exception in a future release.
RotateN2:<MailVwCtl: 0x103838800>
RotateN2:<MailVwCtl: 0x103838800>
RotateN1:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<MailVwCtl: 0x103838800>
RotateN2:<MailVwCtl: 0x103838800>
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN1:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
Unknown chipRevisionID (0xffffffff)
Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
Attempted to change to mode Portrait with an unsupported device (BackAuto). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
Attempted to change to mode Portrait with an unsupported device (BackWideDual). Auto device for both positions unsupported, returning Auto device for same position anyway (BackAuto).
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
WillDsAr:<MailVwCtl: 0x103838800>
RotateN1:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
DidDsAr:<MailVwCtl: 0x103838800>
<Mail2000ViewController: 0x10350b780>:VwWillAppear:1:x0
willAr:1,Fm:0,20,375,792-<MailVwCtl: 0x103838800>
willAr:1,Bd:0,0,375,792-<MailVwCtl: 0x103838800>
<MailVwCtl: 0x103838800>:VwDidAP:
VwDidAP:Bd:0,0,375,792-<MailVwCtl: 0x103838800>
VwDidAP:Fm:0,20,375,792-<MailVwCtl: 0x103838800>
VwDiDAP:SetFm:0,20,375,792-<MailVwCtl: 0x103838800>
ToolVwSetVwSize0:main,0,24,w=375,h=668,stepInd=0
ToolVwSetVwSize0:toobar_self,0,692,w=375,h=66
ToolVwSetVwSize:w=375,h=792
ToolVwSetVwSize1:main,0,0,w=375,h=727
ToolVwSetVwSize1:ToolBar,0,727,w=375,h=792
RotateN2:<Mail2000ViewController: 0x10350b780>
RotateN2:<Mail2000ViewController: 0x10350b780>
<Mail2000ViewController: 0x10350b780>:VwDidAppear:1:x0
M2KVC_DidAp0:0.000000 0.000000 375.000000 812.000000
Additional Context:
This issue is critical as it affects the user experience severely. Notably, we have a similar issue in our Android app using WebView
. In that case, the file upload options for camera, recording, and file selection do not appear at all, restricting users to only upload files from the phone's storage.
We would like to inquire whether there have been recent changes to the APIs related to WKWebView
and WebView
or any known issues that could be causing this behavior. We are also concerned this might be a side effect of recent bug fixes or updates to WKWebView
.
Additional Context:
This issue appears to be specific to iOS 17. We have tested the same functionality on devices running iOS versions below 17, and the camera and recording options work as expected without any crashes. This suggests that the issue may be introduced in iOS 17.
You can view a video demonstrating the issue at this link: https://share.icloud.com/photos/001voevXriVXsEUmhzGsFBtSA
Environment:
- iOS version: 17.6.1&17.5.1
- Device: iPhone 15 Pro Max& iPhone 12
WKWebView
version: [Your WKWebView version, if known]- App platform: iOS
- Xcode version: 15.1
We appreciate any insights or guidance you can provide on this matter.
Thank you.
Hello,
I am pleased to report that we have identified and resolved the issue related to WKWebView causing the app to crash when selecting camera or recording options during file upload.
Summary of Investigation:
To isolate the problem, we created a new project using Objective-C, where we utilized WebView to load a simple HTML test page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>File Input Example</title>
</head>
<body>
<h1>Select a file</h1>
<input type="file" id="fileInput" accept="image/*,video/*">
</body>
</html>
In our tests, devices running iOS 17.5.1 and 17.6.1 successfully displayed the file upload menu, and users could upload files, select images from the photo library, and use the camera/recording features without issues.
Root Cause:
Upon further review of our main project, we discovered the presence of the following code in the project:
@implementation UIImagePickerController (custom)
- (void)viewDidLoad
{
[super viewDidLoad];
self.modalPresentationStyle = UIModalPresentationCustom;
}
@end
This code snippet attempts to change the modal presentation style, which we suspect introduced a bug causing a layer-related error. This error led to the app crashing immediately after entering the camera mode.
Resolution:
We have removed or corrected the above implementation, and the issue has been resolved. The file upload functionality, including camera and recording features, is now working as expected on all tested iOS versions.
Thank you