WKWebView embed


(E Tip) #1

Hi,
i’ve added a WKWebView to an app i’m developing under iOS, to embed some customer models to be viewed, but i get awful performance even on simulator. Does anyone have experience with WKWebView to embed models ?


(Arthur Jamain) #2

Hey there !

The official Sketchfab app uses a WKWebView to display its models. There was no intrinsic issue with the webview performance, however the context in which it runs is different than for e.g. Safari. The rest of your app consumes an amount of CPU/Memory that the UI around the WKWebview in Safari probably doesn’t reach, hence why you can see a difference in perf. That aside, I see no reason that it should be a problem. Here is an excerpt from the one we use :

    WKWebViewConfiguration* config = [[WKWebViewConfiguration alloc] init];
    ...
    config.mediaPlaybackRequiresUserAction = NO;
    config.allowsInlineMediaPlayback = YES;
    config.requiresUserActionForMediaPlayback = NO;
    ...
    _webView = [[WKWebView alloc] initWithFrame:self.bounds configuration:config];