Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I set the WebKit version used by a WebView...?

I'm using WebKit in an OS X app via the JUCE WebBrowserComponent, a lightweight wrapper around Apple's WebView Objective-C class. I'm compiling on OS X 10.12 with a deployment target of 10.7.

The issue I'm having is that on OS X 10.8, the version of WebKit used by the WebView seems to be different to that used by Safari and I can't figure out how the WebKit version is selected or why they are different.

Running otool -L on Safari, gives me:

otool -L /System/Library/PrivateFrameworks/Safari.framework/Versions/A/Safari | grep WebKit
    /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 536.30.1)
    /System/Library/PrivateFrameworks/WebKit2.framework/Versions/A/WebKit2 (compatibility version 1.0.0, current version 536.30.1)

Running otool -L on the Juce demo gives me:

otool -L JuceDemo | grep WebKit
    /System/Library/Frameworks/WebKit.framework/Versions/A/WebKit (compatibility version 1.0.0, current version 602.2.14)

Firstly, why are the "current version" numbers different, for apparently the same linked framework?

Also, if I point the respective applications at http://browserspy.dk/webkit.php It gives me a AppleWebKit version of 600.8.9 for Safari and a version of 536.30.1 for JUCE Demo.

What accounts for these different version numbers, and how can I configure my application so that my WebView uses the "600.8.9" version of WebKit used by Safari?

like image 386
j b Avatar asked Feb 21 '17 17:02

j b


People also ask

When should the new webkitwebview be displayed to the user?

When using WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES process model, the new WebKitWebView should be related to web_view to share the same web process, see webkit_web_view_new_with_related_view () for more details. The new WebKitWebView should not be displayed to the user until the “ready-to-show” signal is emitted.

What is WebKit and how to use it?

WebKit is a rendering engine library to render web pages in view and windows. It also features a framework to interact with user events such as following links on user clicks. WebKit has become the de facto standard for web browser engines on mobile devices.

What is a WebView?

In summary, you will notice that WebView is just a wrapper view, which holds the handle to the canvas on which WebKit can operate. For almost everything else, it is a pass through to a controller module that manages user interactions, user data, and web requests. So What Is WebKit?

How to build web apps in WebView in Android?

Building web apps in WebView 1 Adding a WebView to your app. To add a WebView to your app, you can either include the <WebView> element in your activity layout, or set the entire Activity window ... 2 Working with WebView on older versions of Android. ... 3 Using JavaScript in WebView. ... 4 Handling page navigation. ... 5 Managing windows. ...


1 Answers

otool version

The current version that otool outputs is the version that was used to link when the app was build.

Safari, WebKit and everything

On the latest macOS release Safari uses the system WebKit version. So macOS Sierra 10.12 with Safari 10 uses /System/Library/Frameworks/WebKit.

Safari also supports older macOS releases. And is updated independently from the system. For example Safari 10 runs on macOS 10.10, 10.11 and 10.12. Now macOS 10.11 was released with Safari 9, but when Safari 10 is installed it uses not the system WebKit. Instead a version in /System/Library/StagedFrameworks/Safari is used.

Why?

New major Safari versions not only add shiny new features, and bugs, they sometimes also remove things. Some ill faded -webkit prefixes come to mind. WebKit is part of the SDK which guaranties you that your app will not break on such updates.

Testing

Here the version output of a test app from WebView and WKWebView:

macOS 10.8.5 (12F2560):

Safari Version 6.2.8 (8537.85.17.9.1)
WebKit Version 600.8.9

Cocoa App
WebView WebKit Version 536.30.1

macOS 10.9.5 (13F1911):

Safari Version 9.1.3 (9537.86.7.8)
WebKit Version 601.7.8

Cocoa App
WebView WebKit Version 537.78.2

macOS 10.10.5 (14F2009):

Safari Version 10.0.1 (10602.2.14.0.7)
WebKit Version 602.2.14

Cocoa App
WebView WebKit Version 600.8.9
WKWebView WebKit Version 600.8.9

macOS 10.11.6 (15G1108):

Safari Version 10.0.1 (11602.2.14.0.7)
WebKit Version 602.2.14

Cocoa App
WebView WebKit Version 601.7.8
WKWebView WebKit Version 601.7.8

Answer

It is not supported to link your app to the Safari WebKit version.

You could include your own WebKit build. But I think it's simpler to write your web code for the old version of your deployment target.

like image 91
catlan Avatar answered Oct 15 '22 11:10

catlan