背景
WKWebviewでSPAなページだとピンチイン・ピンチアウトによる拡大・縮小処理が動作しないことがあった。
デフォルト設定では拡大縮小が有効なはずで、ためしにhttps://www.google.co.jp/
を読み込ませると問題なく拡大・縮小できていた。
対応
ignoresViewportScaleLimitsを設定する。
let config = WKWebViewConfiguration()
config.ignoresViewportScaleLimits = true
webView = WKWebView(frame: .zero, configuration: config)
お悩み
- SPAのように画面要素が動的に入れ替わるものはユーザーによるズーム制御を抑制している場合があるのか?
- SPAで拡大縮小を繰り返しているとWebプロセス側がクラッシュすることがある。※対象ページは動画や画像が多め
0x11f001fa0 - [PID=26962] WebProcessProxy::didClose: (web process 0 crash)
0x11f001fa0 - [PID=26962] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash
0x10e01c420 - ProcessAssertion: Failed to acquire RBS Background assertion 'XPCConnectionTerminationWatchdog' for process because PID 0 is invalid
0x10e01c420 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=0, error: (null)
0x1060c8018 - [pageProxyID=14, webPageID=15, PID=26962] WebPageProxy::processDidTerminate: (pid 26962), reason=Crash
0x1060c8018 - [pageProxyID=14, webPageID=15, PID=26962] WebPageProxy::dispatchProcessDidTerminate: reason=Crash
Could not signal service com.apple.WebKit.GPU: 1: Operation not permitted
0x11f000e40 - GPUProcessProxy::gpuProcessExited: reason=IdleExit
0x11f002650 - [PID=0] WebProcessProxy::gpuProcessExited: reason=IdleExit
0x11f001470 - [PID=32027] WebProcessProxy::didClose: (web process 32027 crash)
0x11f001470 - [PID=32027] WebProcessProxy::processDidTerminateOrFailedToLaunch: reason=Crash
0x10e01c2a0 - ProcessAssertion: Failed to acquire RBS Background assertion 'XPCConnectionTerminationWatchdog' for process because PID 0 is invalid
0x10e01c2a0 - ProcessAssertion::acquireSync Failed to acquire RBS assertion 'XPCConnectionTerminationWatchdog' for process with PID=0, error: (null)
0x1058ae018 - [pageProxyID=14, webPageID=15, PID=32027] WebPageProxy::processDidTerminate: (pid 32027), reason=Crash
0x1058ae018 - [pageProxyID=14, webPageID=15, PID=32027] WebPageProxy::dispatchProcessDidTerminate: reason=Crash
0x1058ae018 - [pageProxyID=14, webPageID=15, PID=32027] WebPageProxy::tryReloadAfterProcessTermination: process crashed and the client did not handle it, not reloading the page because we reached the maximum number of attempts