简体   繁体   English

iOS 应用程序 WKWebView 上传图片时出错

[英]iOS app WKWebView error when uploading image

In a WKWebView I am receiving this warning when I upload the image to our server using FormData via Ajax.WKWebView ,当我通过 Ajax 使用 FormData 将图像上传到我们的服务器时,我收到此警告。 The entire process completes successfully.整个过程顺利完成。

Can anyone suggest what is the missing entitlement.任何人都可以建议缺少的权利是什么。 I have reviewed entitlements related to WKWebView我已查看与WKWebView相关的权利

In the console I see that the pid is associated with "webkit.uploads"在控制台中,我看到 pid 与“webkit.uploads”相关联

"Required client entitlement is missing" requestedReason: FinishTaskUnbounded; “缺少所需的客户端权利”请求原因:FinishTaskUnbounded; reason: FinishTaskUnbounded;原因:FinishTaskUnbounded; flags: PreventTaskSuspend>标志:PreventTaskSuspend>

// xcode debug console on submit   
MyDomain[3002:428982] [ProcessSuspension]  0x104be68a0 - ProcessAssertion() PID 3002 Unable to acquire assertion for process with PID 3002
MyDomain[3002:427999] [ProcessSuspension] 0x104be68a0 - ProcessAssertion::processAssertionWasInvalidated()
MyDomain[3002:428982] [assertion] Error acquiring assertion: <NSError: 0x281b3b6f0; domain: RBSAssertionErrorDomain; code: 2; reason: "Required client entitlement is missing"> {
    userInfo = {
        RBSAssertionAttribute = <RBSLegacyAttribute: 0x100f2ee40; requestedReason: FinishTaskUnbounded; reason: FinishTaskUnbounded; flags: PreventTaskSuspend>;
    }
}


// javascript upload code
var formData=new FormData();
formData.append("action", 'save');

var fileInput = document.getElementById('addImage');
if (fileInput.files && fileInput.files[0]) {
    var file = fileInput.files[0
    formData.append('messageImage', file);
    hasFile = true;
}

if(hasFile){
    $.ajax({
       type: "POST",
       url: "/images/save",
       data: formData,
       dataType: 'json',
       contentType: false,
       processData: false,
       success: function(result){}
    });
}

I had a hunch about this and other errors coming from wkWebView, and I think I proved it.我对来自 wkWebView 的这个和其他错误有预感,我想我证明了这一点。 It has to do with the file uploads taking too long, and iOS complains about it, and wkWebView gets "released" (according to another thread).它与文件上传时间过长有关,iOS 抱怨它,并且 wkWebView 被“释放”(根据另一个线程)。 In my case, my uploads were taking between 5 and 13 seconds.就我而言,我的上传需要 5 到 13 秒。

I implemented my upload in a Web Worker, which turned out to be a little tricky on Cordova, but all of the issues went away once I did this.我在 Web Worker 中实现了我的上传,结果在 Cordova 上有点棘手,但是一旦我这样做了,所有问题都消失了。

So my fix only seemed to address this in the emulator on my dev machine, which is using iOS 13.3.所以我的修复似乎只在我的开发机器上的模拟器中解决了这个问题,它使用的是 iOS 13.3。 When I build on my "production" machine running iOS 13.7 the error returns.当我在运行 iOS 13.7 的“生产”机器上构建时,错误返回。 It was happening on both environments before moving file upload to a Worker.在将文件上传到 Worker 之前,这两种环境都发生了这种情况。

It would seem Apple is in the process of adding something to iOS that is triggering these but has not yet documented or explained it.似乎苹果正在向 iOS 添加一些触发这些但尚未记录或解释的内容。 That's my new theory.这是我的新理论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将图像从iOS应用上传到服务器时出错 - Error with uploading image from iOS app to server IPad模拟器很好,但是当使用WKWebview上传图像时,IPad会崩溃应用程序 - IPad Simulator fine but IPad crashes app when uploading image using WKWebview 如何在iOS上使用AWS上载图像时解决错误 - How to resolve an error when uploading an image with AWS on iOS 上载图片时iOS的Firebase错误:对象不存在 - Firebase for iOS error when uploading an image: object does not exist WKWebview如何处理上传图片? - How to Handle Image uploading in WKWebview? 通过帖子上传图像时,iOS AFNetworking内部服务器错误(500) - iOS AFNetworking internal server error (500) when uploading an image by post 将iOS应用上传到商店时出错 - error uploading iOS app to the store 更新到Xcode 7.0.1后上载iOS应用程序时出错 - Error when uploading iOS app after updating to Xcode 7.0.1 上传应用截图时appstoreconnect错误IMAGE_TOOL_FAILURE - appstoreconnect error IMAGE_TOOL_FAILURE when uploading app screenshots WKwebView 在 iOS 应用程序中间歇性给出错误,WebPageProxy 错误代码为 1003 - WKwebView give error intermittently with WebPageProxy error code 1003 in iOS app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM