Skip to content

Commit

Permalink
Merge pull request #198 from robertcnst/fix_ios_shared_process_pool_w…
Browse files Browse the repository at this point in the history
…eb_view

- added a shared WKProcessPool for webview instances
  • Loading branch information
pichillilorenzo authored Nov 19, 2019
2 parents f6353b8 + 5648001 commit 6edf5f0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ios/Classes/FlutterWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {

let options = InAppWebViewOptions()
options.parse(options: initialOptions)
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: options)
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: options, webViewProcessPool: SwiftFlutterPlugin.webViewProcessPool)

webView = InAppWebView(frame: frame, configuration: preWebviewConfiguration, IABController: nil, IAWController: self)
let channelName = "com.pichillilorenzo/flutter_inappwebview_" + String(viewId)
Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/InAppBrowserWebViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class InAppBrowserWebViewController: UIViewController, UIScrollViewDelegate, WKU

override func viewWillAppear(_ animated: Bool) {
if !viewPrepared {
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: webViewOptions)
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: webViewOptions, webViewProcessPool: SwiftFlutterPlugin.webViewProcessPool)
self.webView = InAppWebView(frame: .zero, configuration: preWebviewConfiguration, IABController: self, IAWController: nil)
self.containerWebView.addSubview(self.webView)
prepareConstraints()
Expand Down
3 changes: 2 additions & 1 deletion ios/Classes/InAppWebView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, WKNavi
}
}

public static func preWKWebViewConfiguration(options: InAppWebViewOptions?) -> WKWebViewConfiguration {
public static func preWKWebViewConfiguration(options: InAppWebViewOptions?, webViewProcessPool: WKProcessPool) -> WKWebViewConfiguration {
let configuration = WKWebViewConfiguration()
configuration.processPool = webViewProcessPool

if #available(iOS 10.0, *) {
configuration.mediaTypesRequiringUserActionForPlayback = ((options?.mediaPlaybackRequiresUserGesture)!) ? .all : []
Expand Down
1 change: 1 addition & 0 deletions ios/Classes/SwiftFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class SwiftFlutterPlugin: NSObject, FlutterPlugin {
static var registrar: FlutterPluginRegistrar?
static var channel: FlutterMethodChannel?

static let webViewProcessPool: WKProcessPool = WKProcessPool()
var webViewControllers: [String: InAppBrowserWebViewController?] = [:]
var safariViewControllers: [String: Any?] = [:]

Expand Down

0 comments on commit 6edf5f0

Please sign in to comment.