以下是包含完整日誌的回報範本:
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.
WebKit JS
RSS for tagAccess and modify DOM elements within a webpage, including touch events and visual effects, using WebKit JS.
Posts under WebKit JS tag
63 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
If a sufficiently long text in an HTML tag leads to a text wrap, the calculated values (y and width) of getBoundingClientRect for characters or words directly after the wrap are not correct, if the element or one of a parent is contenteditable="true"
the y value has the value as if it were still before the break
the width value spans the entire width,
Here a code that reproduces this failure:
https://stackblitz.com/edit/vitejs-vite-jwghts?file=src%2Fmain.ts,src%2FcalcLetterRects.ts,src%2Fstyle.css
When using the system input method to input Chinese, deleting the input character will crash when the last character is deleted.
crash info:
reason:NSMutableRLEArray objectAtIndex:effectiveRange:: Out of bounds
-[WKContentView(WKInteraction) setAttributedMarkedText:selectedRange:]_block_invoke
-[WKContentView(WKInteraction)
objc_msgSend$attributesAtIndex:effectiveRange:
(像是WebKit处理系统输入法删除输入信息时,处理文本编辑的问题)
We have tested on iPhone 12 Pro and observed that Safari allowed approximately 1.5GB of RAM usage. Page refreshes when trying to allocate more memory. After performing a hard reset and erasing all content, I noticed that Safari allowed approximately 3GB of RAM usage for our webpage. However, after 2-3 days, the maximum allowable RAM usage in Safari decreases to about 1.5GB. Once 1.5GB limit is reached, the system reloads the page.
To further investigate, I performed another hard reset on my device, and once again, Safari allowed around 3GB of RAM usage.
Additionally, we tested this on iPhone 15 Pro and 15 Pro Max, where the RAM limitation in Safari is consistently around 3GB (page is reloading after reaching 3GB).
Could you please clarify why the memory limit fluctuates after hard reset? Is there any specific setting or flag within Safari or iPhone that controls the maximum RAM usage, which could be causing this behavior?
I also posted the issue there: https://bugs.webkit.org/show_bug.cgi?id=277848
I would appreciate any guidance or potential solutions to this issue. If this is a known limitation or issue, understanding the root cause would be extremely helpful.
Thank you for your attention to this matter.
Model Name: iPhone 12 Pro
iOS Version: 17.5.1
Capacity: 128gb
I encountered an issue when playing WebRTC video using the H5 video tag on an iPhone with iOS 17.
After performing the following operations, the video automatically plays in fullscreen mode:
Create the video tag, specify the playback source, and set the autoplay attribute to true.
Call the API to enter fullscreen playback mode.
Exit fullscreen by swiping with a finger.
Stop playback and destroy the video tag.
Repeat step 1;
at this point, the video does not correctly default to inline playback but instead automatically plays in fullscreen.
It seems as if the system has cached the previous fullscreen state, even though I have exited fullscreen, and the same result occurs with different browsers.
I have set the 'playsinline' and 'webkit-playsinline' attributes for the video tag.
Anyone encountered the same issue? I would appreciate any solutions that can be shared.
I have some questions about the behavior of encode.
For example, with the following code, when we encode a very large string, the result is an empty array.
So if memory allocation fails due to insufficient system memory or other reasons, and the returned Uint8Array is not successfully created, what will we get? An empty array, an exception, or an OOM crash?
const encoder = new TextEncoder();
const encoded = encoder.encode(largeText);
We are encountering a crash that occurs more frequently on iOS 18 beta 3 and beta 4. The crash happens suddenly after startup and does not provide a detailed code stack trace. Additionally, we have noticed that WebKit has a new version with fixes available. Could you let us know when this update will be released?
webkit has fix this crash: https://github.com/WebKit/WebKit/commit/03200a8c08079e188c3de7a97109a51202cc6c64
https://bugs.webkit.org/show_bug.cgi?id=276620
Thread 1 Queue : com.apple.main-thread (serial)
#0 0x00000001921c7008 in objc_msgSend ().
#1 0x00000001f2848938 in **::Detail::CallableWrapper<WebViewRenderingUpdateScheduler::WebViewRenderingUpdateScheduler(WebView)::$_1, void>::call() ()
#2 0x0000000194e7bf74 in CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION ().
#3 0x0000000194e7bd18 in __CFRunLoopDoObservers ().
#4 0x0000000194eaac80 in __CFRunLoopRun ()
#5 0x0000000194eaa4c8 in CFRunLoopRunSpecific ().
#6 0x00000001e172d1c4 in GSEventRunModal ().
#7 0x00000001979f4a90 in -[UIApplication _run] ()
#8 0x0000000197aa2d1c in UIApplicationMain ().
#9 0x00000001023f4064 in main at /Users/Dragon/Desktop/App/qrn-ios//main.m:14.
#10 0x00000001bb60e9b4 in start ().
detail info is below:
SIGSEGV: 0xffffff81ece07608 0x0 + 8268181504
main.
0 0 0x00000001018de5c8 -[CKCrashReporter recordCrashWithSignal:].
1 1 0x00000001018e15cc SignalHandler.
2 2 libsystem_platform.dylib 0x000000021716fafc 93D52E6D-C21D-3BC4-9C49-EBF71987F78C + 8977309696
3 3 WebKitLegacy 0xffffff81ece07608 0x0 + 8268181504.
4 4 WebKitLegacy 0x00000001ece07608 5BEE83EA-6DB3-357D-A484-0555DAE5C1B8 + 8268181504.
5 5 CoreFoundation 0x000000018fbd6e14 7AD2298D-5B8F-3AF4-9EED-B09B8E0A9653 + 6706372608.
6 6 CoreFoundation 0x000000018fbd6bb8 7AD2298D-5B8F-3AF4-9EED-B09B8E0A9653 + 6706372608.
7 7 CoreFoundation 0x000000018fc05bd8 7AD2298D-5B8F-3AF4-9EED-B09B8E0A9653 + 6706372608.
8 8 CoreFoundation 0x000000018fc05368 CFRunLoopRunSpecific + 6706372608.
9 9 GraphicsServices 0x00000001dbdf81c4 GSEventRunModal + 7983820800.
10 10 UIKitCore 0x00000001927529b0 D2E47210-1C46-3CA7-BBC2-35021B146A13 + 6748045312.
11 11 UIKitCore 0x00000001928 00d54 UIApplicationMain + 6748045312.
12 12 0x00000001000b4080 main.
13 13 dyld 0x00000001b5e40734 94AF19E0-4F2A-332F-A08C-04B9B7CB6FAC + 210740.
I have a React website that uses getUserMedia to capture user audio. I'm displaying this website in an iOS mobile app using UIWebView in SwiftUI. The audio is correctly captured when the app is in focus. However, when the app goes to the home screen and runs in the background, the microphone audio gets cut off. This issue does not occur when the website is opened in iOS Safari.
Here's my Info.plist and .entitlements file. I granted most, if not all, permissions for both files in an attempt to get it to work, but it still doesn't resolve the issue.
Info.plist
audio
bluetooth-central
bluetooth-peripheral
external-accessory
fetch
location
nearby-interaction
processing
push-to-talk
remote-notification
voip
Entitlements.plist
com.apple.developer.push-to-talk: true
com.apple.developer.spatial-audio.profile-access: true
inter-app-audio: true
Dear Apple Support Team,
Upon upgrading to iOS 18, I have noticed a marked change in the character spacing of the PingFang font when rendered by WebKit, the web content rendering engine utilized by Safari and other web views in iOS. Specifically, the spacing between characters appears to have increased or altered in a manner that is not consistent with previous iOS versions or with the font's specifications as defined in CSS. This issue has significantly impacted the visual presentation of my web pages, causing a notable deviation from the intended design and potentially affecting user experience.
Expected Behavior:
The character spacing of PingFang font in WebKit on iOS 18 should maintain consistency with previous versions or adhere strictly to CSS specifications, ensuring a seamless transition for web developers and end-users alike.
Request for Assistance:
Could you please investigate this issue and confirm if it is a known bug or an intentional change in iOS 18? If it's a bug, could you provide an estimated timeline for a fix or a workaround that we can implement in the meantime? Additionally, any guidance on how to best address this issue in our H5 content, such as alternative font choices or CSS hacks, would be greatly appreciated. Thank you for your attention to this matter. We value the stability and consistency of the WebKit engine and the overall iOS platform, and we look forward to your prompt response and resolution.
Hi:
I saw the post WWDC WebKit release notes said Safari will support largeblob extension from version 17. But when I create a credential with largeblob extension, different action takes according what authenticator used.
The credential options is:
"credCreateOptions": {
"rp": {
"name": "WebAuthn demo",
"id": "webauthn.turinggear.com"
},
"user": {
"name": "Jonathon.Runte97@gmail.com",
"displayName": "Jonathon.Runte97@gmail.com",
"id": "bqShD9YGRicjM-1foXiBqrdCzTHTuG1bkmKaxzn7oEM"
},
"challenge": "9BP4y2epk2b3MhRCRRS5tt4bdWYLPJcKBLMMiB_7p7E",
"pubKeyCredParams": [
{
"alg": -7,
"type": "public-key"
},
{
"alg": -257,
"type": "public-key"
}
],
"excludeCredentials": [],
"authenticatorSelection": {
"requireResidentKey": true,
"residentKey": "required",
"userVerification": "discouraged"
},
"attestation": "none",
"extensions": {
"credProps": true,
"largeBlob": {
"support": "preferred"
}
}
}
When i choose use iPhone be my authenticator, it seems that largeblob act as it should be:
"credential" : {
"id": "ZRxBdH4LKE4eiVxbwcA4Kmn9VZk",
"rawId": "ZRxBdH4LKE4eiVxbwcA4Kmn9VZk",
"response": {
"attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YViYSETDPyxegNfyH_fI_8t9iVRDn34LxYd8YH1k2u4xSk5dAAAAAPv8MAcVTk7MjAtuAgVX170AFGUcQXR-CyhOHolcW8HAOCpp_VWZpQECAyYgASFYICY6gkqg6OG_v1BlGCPj7gSwsu_c0vTmVzmfd7TsqEh5Ilgg_Cn0mAiO8QCx7J1xw809VBq8iI-U5pgY0I947B7XF9g",
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiOVcta3RMbEswemZDSXpFb2hNd3E3OTgxQXJlRzV0aEVBdmRHdXNHcUsxcyIsIm9yaWdpbiI6Imh0dHBzOi8vd2ViYXV0aG4udHVyaW5nZ2Vhci5jb20ifQ",
"transports": [
"internal",
"hybrid"
],
"publicKeyAlgorithm": -7,
"publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEJjqCSqDo4b-_UGUYI-PuBLCy79zS9OZXOZ93tOyoSHn8KfSYCI7xALHsnXHDzT1UGryIj5TmmBjQj3jsHtcX2A",
"authenticatorData": "SETDPyxegNfyH_fI_8t9iVRDn34LxYd8YH1k2u4xSk5dAAAAAPv8MAcVTk7MjAtuAgVX170AFGUcQXR-CyhOHolcW8HAOCpp_VWZpQECAyYgASFYICY6gkqg6OG_v1BlGCPj7gSwsu_c0vTmVzmfd7TsqEh5Ilgg_Cn0mAiO8QCx7J1xw809VBq8iI-U5pgY0I947B7XF9g"
},
"type": "public-key",
"clientExtensionResults": {
"largeBlob": {
"supported": true
}
},
"authenticatorAttachment": "platform"
}
Safari returns clientExtensionResults.largeBlob.supported= ture.
But when I use an NFC authenticator with the same credCreateOptions, safari didnot return clientExtensionResults section. Response as follows(ignore the challenge and others random data):
"credential" : {
"id": "uEVMzgsINXj7bHFD5Z5xbMGJ7k6tnrMQSLjB4yB8_0GxbUPoWYUYX8E3D9XB24Cv-PMh6cRpCFt5klUHqsot2Yc48BVu5TN8sbabTgped2x46ljdsxFzaNCA8D2y9FZK8BHLLZTKHNuzJw4SCYUkzg",
"rawId": "uEVMzgsINXj7bHFD5Z5xbMGJ7k6tnrMQSLjB4yB8_0GxbUPoWYUYX8E3D9XB24Cv-PMh6cRpCFt5klUHqsot2Yc48BVu5TN8sbabTgped2x46ljdsxFzaNCA8D2y9FZK8BHLLZTKHNuzJw4SCYUkzg",
"response": {
"attestationObject": "o2NmbXRkbm9uZWdhdHRTdG10oGhhdXRoRGF0YVj0SETDPyxegNfyH_fI_8t9iVRDn34LxYd8YH1k2u4xSk5FAAABeAAAAAAAAAAAAAAAAAAAAAAAcLhFTM4LCDV4-2xxQ-WecWzBie5OrZ6zEEi4weMgfP9BsW1D6FmFGF_BNw_VwduAr_jzIenEaQhbeZJVB6rKLdmHOPAVbuUzfLG2m04KXndseOpY3bMRc2jQgPA9svRWSvARyy2UyhzbsycOEgmFJM6lAQIDJiABIVggg2LXO5Q2U0ETrSxrLKxCfKKCTCitTCx9bpxD1Gw917ciWCDsxnw4Wd7M_UTiGQJ7swCMXN83nprsT8wkTlftXRizmw",
"clientDataJSON": "eyJ0eXBlIjoid2ViYXV0aG4uY3JlYXRlIiwiY2hhbGxlbmdlIjoiOUJQNHkyZXBrMmIzTWhSQ1JSUzV0dDRiZFdZTFBKY0tCTE1NaUJfN3A3RSIsIm9yaWdpbiI6Imh0dHBzOi8vd2ViYXV0aG4udHVyaW5nZ2Vhci5jb20ifQ",
"transports": [
"nfc"
],
"publicKeyAlgorithm": -7,
"publicKey": "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEg2LXO5Q2U0ETrSxrLKxCfKKCTCitTCx9bpxD1Gw917fsxnw4Wd7M_UTiGQJ7swCMXN83nprsT8wkTlftXRizmw",
"authenticatorData": "SETDPyxegNfyH_fI_8t9iVRDn34LxYd8YH1k2u4xSk5FAAABeAAAAAAAAAAAAAAAAAAAAAAAcLhFTM4LCDV4-2xxQ-WecWzBie5OrZ6zEEi4weMgfP9BsW1D6FmFGF_BNw_VwduAr_jzIenEaQhbeZJVB6rKLdmHOPAVbuUzfLG2m04KXndseOpY3bMRc2jQgPA9svRWSvARyy2UyhzbsycOEgmFJM6lAQIDJiABIVggg2LXO5Q2U0ETrSxrLKxCfKKCTCitTCx9bpxD1Gw917ciWCDsxnw4Wd7M_UTiGQJ7swCMXN83nprsT8wkTlftXRizmw"
},
"type": "public-key",
"clientExtensionResults": {},
"authenticatorAttachment": "cross-platform"
}
Even without a clientExtensionResults.largeBlob.supported= false.
According to w3c, it should return clientExtensionResults.largeBlob.supported= false ?
The NFC authenticaor do support largeblob extensions and act write with the same credCreateOptions on edge on windows.
Does safari need some extra parameters?
My safari is the newest version of 17.5 (19618.2.12.11.6), mac version is Sonoma 14.5(23F79).
Thank you very much.
In my project, I'm using the WKWebView to display the Google OAuth popup. And after it appears, the JS window.opener is null, and because of that the original window cannot receive an auth token in a callback. This works perfectly fine in iOS 17.0 and earlier, but broken starting from 17.5. I've tested on the 18.0 too - same results the opener is always null no matter what I try.
Web Part:
<html>
<head>
<script src="https://accounts.google.com/gsi/client" async></script>
</head>
<script type="text/javascript">
var global = {};
window.addEventListener("message", function (ev) {
console.log("=== Event Listener ===");
console.log(ev);
});
function client() {
if (global.client === undefined) {
global.client = google.accounts.oauth2.initTokenClient({
client_id: '<client_id>',
scope: 'https://www.googleapis.com/auth/userinfo.email \
https://www.googleapis.com/auth/userinfo.profile',
callback: function (responseToken) {
console.log("=== Callback ===");
console.log(responseToken);
let auth = document.getElementById("auth");
auth.textContent = 'Token: ' + responseToken.access_token
}
});
}
return global.client;
}
function googleOauthClient() {
console.log("Trying to login");
let auth = document.getElementById("auth");
auth.textContent = 'In Progress...';
client().requestAccessToken();
}
</script>
<body>
<div id="center">
<a onclick="googleOauthClient()"><h1>Google Login Attempt</h1></a>
<h2 id="auth"></h2>
</div>
</body>
</html>
In iOS showing popup is implemented as:
#import "WebViewController.h"
#import "SafariServices/SafariServices.h"
@interface WebViewController () <WKNavigationDelegate, WKUIDelegate> {
WKWebView *web;
WKWebView *popupWebView;
}
@end
@implementation WebViewController
- (void)loadView {
[super loadView];
WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
[[config preferences] setJavaScriptEnabled:YES];
[[config preferences] setJavaScriptCanOpenWindowsAutomatically:NO];
[[config defaultWebpagePreferences] setAllowsContentJavaScript:YES];
[config setAllowsInlineMediaPlayback:YES];
web = [[WKWebView alloc] initWithFrame:self.view.frame configuration:config];
[web setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[web setAllowsLinkPreview:YES];
[web setNavigationDelegate:self];
[web setUIDelegate:self];
[web setInspectable:YES];
[web setCustomUserAgent:[[web valueForKey:@"userAgent"] stringByAppendingString:@" Safari"]];
[[self view] addSubview:web];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString *url = @"http://localhost:8080/oauth"; // A simple Spring Boot App where HTML is hosted
[web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:url]]];
}
- (void)webView:(WKWebView *)webView
decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction
decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
decisionHandler(WKNavigationActionPolicyAllow);
}
- (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures {
if (navigationAction.targetFrame == nil) {
popupWebView = [[WKWebView alloc] initWithFrame:webView.frame configuration:configuration];
[popupWebView setCustomUserAgent: [webView customUserAgent]];
[popupWebView setUIDelegate:self];
[popupWebView setNavigationDelegate:self];
[popupWebView setInspectable:true];
[[[popupWebView configuration] defaultWebpagePreferences] setAllowsContentJavaScript:YES];
[[[popupWebView configuration] preferences] setJavaScriptCanOpenWindowsAutomatically:NO];
[[[popupWebView configuration] preferences] setJavaScriptEnabled:YES];
[[popupWebView configuration] setSuppressesIncrementalRendering:YES];
[webView addSubview:popupWebView];
[popupWebView loadRequest:[navigationAction.request copy]];
return popupWebView;
}
return nil;
}
- (void)webViewDidClose:(WKWebView *)webView {
[webView removeFromSuperview];
popupWebView = nil;
}
- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error {
NSLog(@"didFailProvisionalNavigation: %@", [error description]);
}
- (void)webView:(WKWebView *)webView didFailNavigation:(null_unspecified WKNavigation *)navigation withError:(NSError *)error {
NSLog(@"didFailNavigation: %@", [error description]);
}
- (void)webView:(WKWebView *)webView requestMediaCapturePermissionForOrigin:(WKSecurityOrigin *)origin initiatedByFrame:(WKFrameInfo *)frame
type:(WKMediaCaptureType)type decisionHandler:(void (^)(WKPermissionDecision decision))decisionHandler {
decisionHandler(WKPermissionDecisionGrant);
}
- (void)webView:(WKWebView *)webView requestDeviceOrientationAndMotionPermissionForOrigin:(WKSecurityOrigin *)origin
initiatedByFrame:(WKFrameInfo *)frame decisionHandler:(void (^)(WKPermissionDecision decision))decisionHandler {
decisionHandler(WKPermissionDecisionGrant);
}
- (void)webView:(WKWebView *)webView runOpenPanelWithParameters:(WKOpenPanelParameters *)parameters
initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(NSArray<NSURL *> * _Nullable URLs))completionHandler {
completionHandler(nil);
}
@end
What I tried so far:
Disabled in the Settings -> Safari -> Cross-Origin-Opener-Policy;
Disabled popup blocking;
Added Allow Arbitrary Loads to Info.plist (actually added all possible security policies);
This actually works in the SFSafariViewController, but I cannot use it because I need to hide the Navigation and Status bar panels.
How it looks in 17.0
vs 17.5
And ideas about what I might be doing wrong? Or maybe some workaround I can utilize to get the Google OAuth token from the popup. Thanks in advance.
I use the WKWebView to show my content. And inside it, I also used a shared worker to run my task. And while I move focus out, the WKWebview is still working but the tasks inside shared worker stops. Is this by design or a bug?
Do you have any suggestions to handle this situation to let the task inside shared worker to continue while focus changes.
17.5+, when the wkwebview is not visible, the setTimeout function fails to execute when it reaches time.how to fix?
I am new to swift, so any advice would be appreciated. So the I have seen URL and URLSession return a timeout response, the android varient of my app does not show this issue.
class HasInternet: ObservableObject {
let monitor = NWPathMonitor()
let queue = DispatchQueue(label: "Monitor")
private var status: NWPath.Status = .requiresConnection
@Published var isConnected = false
init(){
monitor.pathUpdateHandler = { [weak self] path in
if let url = URL(string: "https://google.com") {
var request = URLRequest(url: url)
request.httpMethod = "HEAD"
request.timeoutInterval = 30
let sessionConfig = URLSessionConfiguration.default
sessionConfig.timeoutIntervalForRequest = 30.0
sessionConfig.timeoutIntervalForResource = 60.0
URLSession(configuration: sessionConfig)
.dataTask(with: request) { (_, response, error) -> Void in
guard error == nil else {
return
}
guard (response as? HTTPURLResponse)?
.statusCode == 200 else { return }
DispatchQueue.main.async {
self?.isConnected = true
}
}
.resume()
}
}
monitor.start(queue: queue)
}
}
Here is another place with the same behaviour.
func post(dModel: DialogModel? = nil, url: String, type: responseTypes, body: [String: Any], headers: [headerType], async: Bool = true) { //async
let semaphore = DispatchSemaphore(value: 0)
let timeout: TimeInterval = 10
if let url = URL(string: url) {
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 30
for header in headers {
request.setValue(header.value, forHTTPHeaderField: header.key)
}
do {
request.httpBody = try JSONSerialization.data(withJSONObject: body, options: .prettyPrinted)
} catch let error {
self.processError(dModel: dModel, error: error.localizedDescription, type: .report)
return
}
let sessionConfig = URLSessionConfiguration.default
sessionConfig.timeoutIntervalForRequest = 30.0
sessionConfig.timeoutIntervalForResource = 60.0
URLSession(configuration: sessionConfig)
.dataTask(with: request) { (data, response, error) -> Void in
if let error = error {
self.processError(dModel: dModel, error: error.localizedDescription, type: .report)
if(async){
semaphore.signal() // Signal semaphore even in case of error
}
return
}
if let httpResponse = response as? HTTPURLResponse{
if let unWrappedData = data {
if let httpResponseData = String(data: unWrappedData, encoding: .utf8) {
self.parse(dModel: dModel, type: type, response: httpResponseData, statusCode: httpResponse.statusCode)
}
}
} else {
self.processError(error: "Invalid response")
}
if(async){
semaphore.signal() // Signal semaphore after processing the response
}
}
.resume()
if(async){
semaphore.wait(timeout: .now() + timeout)
}
} else {
processError(error: "Invalid URL")
}
}
i can sure the app already hava the camera access, but in the embedded html, i still cannot open the camera. And this HTML page is work at Safari, but cant work on app when the page is embedded in app.
there is the error message:
DOMException: undefine is not an object (evaluating 'navigator.mediaDevices.getUserMedia')
and i also try to use 'navigator.getUserMedia' and 'navigator.mediaDevices.enumerateDevices()', this all dont work.
Since my question exceeds 700 words, please check it in the attachment. Thank you!
Question
We are using a WKWebKit based Cordova application and we are getting WKWebKit crash resulting in blank page.
The same web app is working in browser and other platforms. Upon investigation we found the memory used in iOS app using safari debugger / profiler.
The total memory used is 870.13 MB. Break up of that is
Page: 549MB
JavaScript: 321.13MB
However, the max comparison for memory shown in safari is 1.37GB while the current usage is 870.13MB. Is there any internal memory calculation for crash cutoff?
In this case the current memory is around 62% of the max comparison. Hence, we need to know whether this is the expected behaviour from iOS platform.
JetsamEvent-2024-05-23-102822.ips
Issue Summary:
I have encountered an issue where JavaScript does not execute in a WebView when another UIViewController is presented modally with modalPresentationStyle.fullScreen. This problem only occurs on physical devices running iOS 17.5.1. The issue is not present on iOS 17.5 simulators or devices running iOS 17.4.1 or earlier.
Reproduction Steps:
Create a ViewController with a WebView.
Load a web page (e.g., https://apple.com) in the WebView.
Present another ViewController modally with modalPresentationStyle.fullScreen.
Verify that JavaScript execution in the initial WebView stops working.
Test Code:
import UIKit
import WebKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the WebView
let configuration = WKWebViewConfiguration()
let webView = WKWebView(frame: view.frame, configuration: configuration)
view.addSubview(webView)
webView.frame = view.frame
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
webView.load(URLRequest(url: URL(string: "https://apple.com")!))
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let navigationController = UINavigationController(rootViewController: TargetViewController())
navigationController.modalPresentationStyle = .fullScreen
present(navigationController, animated: true)
}
}
class TargetViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Set up the WebView
let webView = WKWebView(frame: view.frame, configuration: WKWebViewConfiguration())
view.addSubview(webView)
webView.frame = view.frame
if #available(iOS 16.4, *) {
webView.isInspectable = true
} else {
// Fallback on earlier versions
}
webView.load(URLRequest(url: URL(string: "https://apple.com")!))
}
}
Observations:
The JavaScript within the WebView stops executing only on physical devices running iOS 17.5.1.
This issue does not occur on the iOS 17.5 simulator.
Devices running iOS 17.4.1 or earlier do not experience this issue.
Request for Assistance:
Could you please provide any insights or potential workarounds for this issue? Additionally, if this is a known bug, any information on upcoming fixes would be highly appreciated.
Thank you.
Hi
In my app I've to complete the IDV [Identity verification] by capturing the face os user and his/her documents, for this the backend developer provides me the URL from the IDV 3rd party, which URL I do open in webview, so before during loading the camera captureing screen in webview the Live Broadcast screen pops up from no where. I don't want this Live Broadcast screen but somehow it opens anyway. Although it is good thing that my expected camera screen was still open in background so I can go further from there.
First time I'm also bit confused like how this kind of screen popsup even if I did't code for it. Also it takes me a little bit time to figure out how to close that screen.
Simple peoples/users who're going to use my app they don't know how to close it. Please check the screenshots I attached. Please help me to rid of this popup.
Thank You
I have the following html that is opened in a WKWebView.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Popup Window Test</title>
</head>
<body>
<textarea id="myTextarea" cols="5" rows="1">Empty</textarea>
<script>
function openWindow() {
const popup = window.open(
"https://www.apple.com/",
"PopupSample",
"width=400,height=400,dialog=yes,dependent=yes,scrollbars=yes,location=yes"
);
console.log("Popup closed: ", popup.closed);
document.getElementById("myTextarea").value = popup.closed
? "Closed"
: "Open";
const timer = setInterval(() => {
console.log(popup.location.href);
if (popup.closed) {
clearInterval(timer);
console.log("Popup closed: ", popup.closed);
document.getElementById("myTextarea").value = "Closed";
}
}, 1000);
}
</script>
<button onclick="openWindow()">Open Window</button>
</body>
</html>
When I click the button and open page "https://www.apple.com/" in another WKWebView, the javascript code does not work as expected here, the popup object returned from window.open() does not refer to the valid window object, and the closed property is set to true even the new popup window is still alive.
This is a regression since MacOS14.4 updated, I've reported to apple DTS, but they said it's out of their scope.
Does anyone has any clue about this?