Post

Replies

Boosts

Views

Activity

WKWebView offscreen rendering
I'm trying to integrate WKWebView to metal rendering pipline and met 2 issues. WKWebView will kick webview rendering only when the WKWebView control is visible, i have been looking around WKWebView related header files and configurations, didn't find a way to force WkWebView render the view for every single frame when the control is invisible or not part of view hierarchy . Low performance when access CGImage pixel data returned from WKWebview takesnapshot, in order to get the pixel data uploaded to MTLTexture i did the following tests: Access the pixel data through CGDataProviderCopyData, the CPU usage is very high, main thread drop to 37 FPS on IPhone 8 Plus simulator, most CPU cycles spend on function vConvert_PermuteChannels_ARGB8888_CV_vec, i also try to render the CGImage to a BitmapContext but still can't get ride of vConvert_PermuteChannels_ARGB8888_CV_vec.       CGDataProviderRef provider = CGImageGetDataProvider(cgImage);       CFDataRef rawData = CGDataProviderCopyData( provider );       CFIndex length = CFDataGetLength( rawData );       UInt8 *buf = (UInt8*) CFDataGetBytePtr( rawData );       MTLRegion region = {         {0, 0, 0},         {1280, 960, 1}       };           [_webviewTexture replaceRegion:region mipmapLevel:0 withBytes:buf bytesPerRow:bytesPerRow];       CFRelease( rawData ); Another try is create metal texture from CGImage via textureLoader but failed with error "image decoding failed"        MTKTextureLoader *loader = [[MTKTextureLoader alloc] initWithDevice: _device];       NSDictionary *textureLoaderOption = @{         MTKTextureLoaderOptionTextureUsage:@(MTLTextureUsageShaderRead),         MTKTextureLoaderOptionTextureStorageMode : @(MTLStorageModePrivate)       };       NSError *error = nil;       _webviewTexture = [ loader newTextureWithCGImage:cgImage options:textureLoaderOption error:&error]; Any idea against how to force kick WebView rendering or more efficient way to access CGImage raw pixel data would be greatly appreciated.
3
0
2.0k
Jul ’22