SPB Git

Repository Public License

WEBKIT_LIMITATIONS.md 20.9 KB

# What WKWebView cannot do (or does differently from Safari)

ORIX Navigator renders the web with WKWebView and public API only. This page lists what that implies, the fallback the browser uses, and how each statement was established.

Legend for the "Basis" lines:

  • Header — read in the WebKit / AuthenticationServices headers of the Xcode 27.2 SDKs (macOS 27.2, iOS 27.2).
  • Test — exercised by Tests/WebRuntimeTests on macOS 27.0 against the local fixture server.
  • Apple docs / known behaviour — documented by Apple or long-standing WebKit behaviour; not verified in this repository. Treat it as a claim to confirm before relying on it.

# 1. Extensions

  • Safari's extensions (Safari Web Extensions, Safari App Extensions, Safari content blockers installed from the App Store) belong to Safari. A WKWebView in another app does not load them and there is no API to enumerate or enable them.
  • Since macOS 15.4 / iOS 18.4 WebKit ships a public WKWebExtension / WKWebExtensionController API (WKWebViewConfiguration.webExtensionController) that lets an app load and run WebExtensions it manages itself: the app must implement the tabs/windows model (WKWebExtensionTab, WKWebExtensionWindow), the permission prompts and the toolbar UI. Nothing is inherited from Safari.
  • Fallback in ORIX Navigator: content blocking is done with WKContentRuleList (compiled by ContentRuleListCompiler, attached per profile); user styles through Morph (CSS only, isolated world); user scripts through WebEngine.installUserScript (isolated worlds only). A WKWebExtensionController host is not implemented in WebRuntime.
  • Basis: Header (WKWebExtension*.h, availability macos(15.4), ios(18.4)); content rule lists: Test.

# 2. DRM / Encrypted Media Extensions

  • WebKit implements EME with FairPlay Streaming only. Widevine and PlayReady are not available, so services that offer only those key systems will not play protected video. There is no API to add a CDM.
  • WKWebsiteDataTypeMediaKeys exists to list/remove stored media keys (exposed as WebsiteDataKind.mediaKeys).
  • Fallback: none possible. The UI should surface the page's own "unsupported browser" message; do not spoof a Chrome user agent to hide it, playback would still fail.
  • Basis: WKWebsiteDataTypeMediaKeys — Header. Key-system support — Apple docs / known behaviour, not verified.

# 3. Passkeys / WebAuthn

  • A page's navigator.credentials.create/get inside WKWebView is handled by the system only when the embedding app is entitled for it. A general-purpose browser needs Apple's web-browser entitlement (com.apple.developer.web-browser, granted on request; on iOS it is also the default-browser entitlement) so that WebKit accepts WebAuthn for arbitrary relying parties. Without it, WebAuthn in a web view is limited to domains the app is associated with (webcredentials: Associated Domains).
  • AuthenticationServices additionally offers a browser-specific API, ASAuthorizationWebBrowserPublicKeyCredentialManager and the ASAuthorizationWebBrowser… request types (macOS 13.3, iOS 17.4), for browsers that run the WebAuthn ceremony themselves; it requires its own entitlement (com.apple.developer.web-browser.public-key-credential per Apple's documentation) and a user authorisation (requestAuthorizationForPublicKeyCredentials).
  • Passkeys created in Safari live in the user's credential provider (iCloud Keychain or a third-party one), so they are usable from an entitled browser; a non-entitled build simply gets NotAllowedError.
  • Fallback: WebRuntime does nothing special: with the entitlement WebKit shows the system sheet; without it the page's WebAuthn calls fail and the site falls back to its password flow.
  • Basis: existence and availability of the ASAuthorizationWebBrowser… API — Header. Entitlement names and WKWebView behaviour with/without them — Apple docs, not verified (the test host is an unsigned process).

# 4. Default browser

  • iOS / iPadOS: an app can be chosen as default browser only with the managed entitlement com.apple.developer.web-browser, requested from Apple, and by declaring the http/https URL schemes. The entitlement comes with rules (no UIWebView, must open any URL, etc.).
  • macOS: no entitlement. The app declares http/https in CFBundleURLTypes (and HTML document types) and asks the system to become the handler (NSWorkspace.setDefaultApplication(at:toOpenURLsWithScheme:)); the system shows its own confirmation.
  • Related: on iOS the same entitlement is what unlocks service workers and WebAuthn for arbitrary sites (§3, §7).
  • Basis: Apple docs, not verified here (nothing in WebRuntime depends on it).

# 5. Geolocation

  • OS 27 and later: WKUIDelegate has webView(_:requestGeolocationPermissionFor:initiatedBy:) (macos(27.0), ios(27.0)). WebRuntime implements it and routes it through PermissionProvider / WebEngineUIDelegate like camera and microphone (PermissionKind.location, keyed by the top-level origin).
  • Before OS 27 (the package still deploys to macOS 15 / iOS 18): there is no public per-origin delegate. WebKit decides by itself: the app's own CoreLocation authorisation is required first (NSLocationWhenInUseUsageDescription), then WebKit presents its own per-site prompt. The browser can neither restyle that prompt, nor remember "always allow / never" in its own permission store, nor revoke it per site. ORIX Navigator's site-permission UI must therefore present "location" as managed by the system on OS 15–26.
  • The decision is made by WebKit, the position by CoreLocation: the app must hold the location authorisation in both cases, and a ghost profile gets no special treatment from the system prompt on old systems.
  • Basis: delegate method and availability — Header; the routing logic (resolvePermission) — Test; the WebKit → delegate hop and the pre-27 behaviour — not verified (needs a visible window and location services).

# 6. Web Push and notifications

  • WKWebView exposes no API for the Push API or for Web Notifications permission. On iOS/iPadOS Web Push exists only for web apps added to the Home Screen; on macOS it is a Safari feature. Pages in a third-party browser's WKWebView see Notification.permission === "denied" / no PushManager.
  • Fallback: none. PermissionKind.notifications exists in the core model but WebRuntime never asks for it; the UI should not offer it as a grantable site permission.
  • Basis: no notification or push symbol in the WebKit headers (searched) — Header. Runtime behaviour — Apple docs, not verified.

# 7. Service workers and App-Bound Domains

  • On iOS/iPadOS, service workers run in WKWebView only for (a) apps holding the web-browser entitlement, or (b) domains listed under WKAppBoundDomains in Info.plist with WKWebViewConfiguration.limitsNavigationsToAppBoundDomains = true — a mode meant for single-site apps, which restricts navigation to at most ten domains and is useless for a browser. WebRuntime leaves the flag off.
  • Consequence without the entitlement on iOS: no offline web apps, no background sync, navigator.serviceWorker absent or rejecting. Service-worker registrations that do exist are listed and removed through WebsiteDataKind.serviceWorkers.
  • Fallback: ship with the entitlement. Offline reading is covered natively by the archive feature (webArchiveData() / pdfData()), not by service workers.
  • Basis: limitsNavigationsToAppBoundDomains, WKErrorNavigationAppBoundDomain, WKWebsiteDataTypeServiceWorkerRegistrations — Header. Entitlement gating and macOS behaviour — Apple docs, not verified.

# 8. Downloads and resume

  • Downloads are WKDownload objects obtained by answering .download to a navigation action/response, or with startDownload(using:). There is no pause: "pause" is cancel that returns resume data, and "resume" is resumeDownload(fromResumeData:). Resume data exists only when the server allows it (range requests and a validator such as ETag); otherwise the download restarts from zero.
  • WebKit refuses a destination that already exists and requires the directory to exist; the destination is chosen once, in decideDestinationUsing. A resumed download keeps writing to the file named in the resume data and does not ask again.
  • Progress is an NSProgress (WKDownload.progress); there is no per-chunk delegate and no speed estimate.
  • Downloads are tied to the web view/process that created them: closing the profile session cancels them (WebProfileRegistry.endGhostSession). iOS 18.2+ adds placeholder files (decidePlaceholderPolicy), not used.
  • blob: and data: URLs can be downloaded (<a download>); they are never shown as top-level documents.
  • Implementation: DownloadCoordinator → DownloadSink (NavigatorCore). Without a sink downloads are cancelled.
  • Basis: Header; attachment, unknown MIME type, download attribute, progress, cancel with resume data and resume from byte N against a range-capable server — Test.

# 9. Picture in Picture and fullscreen

  • iOS: WKWebViewConfiguration.allowsPictureInPictureMediaPlayback (default on) and allowsInlineMediaPlayback. PiP that survives leaving the app needs the app's audio background mode.
  • macOS: no public switch; PiP is available from the video's own controls / the page's webkitSetPresentationMode. The browser cannot start PiP for a tab from native UI.
  • Element fullscreen: WKPreferences.isElementFullscreenEnabled and WKWebView.fullscreenState. While an element is fullscreen WebKit moves the web view into its own window and leaves a placeholder in the app's hierarchy; WebViewContainerView does not re-parent the view in that state.
  • closeAllMediaPresentations() leaves PiP and fullscreen programmatically.
  • Basis: Header. Not exercised by tests (media does not play in an off-screen test web view, see §12).

# 10. Web Inspector

  • WKWebView.isInspectable (macOS 13.3 / iOS 16.4, default off) only makes the page appear in Safari's Develop menu, on the same Mac or on a Mac connected to the device. There is no API to embed the inspector, to open it programmatically, or to read the console, network log or DOM tree.
  • Fallback (Dev module): uncaught errors, unhandled rejections, failed resource loads and CSP violations are captured from an isolated world; console.* output is mirrored only on demand by the single bundled script that runs in the page world (dev-console.js), through a write-only handler that accepts display text and nothing else. No network panel is possible from public API.
  • Basis: Header; capture, mirroring and the handler's confinement — Test.

# 11. Printing, PDF, archives, snapshots

  • macOS: printOperation(with:) returns an NSPrintOperation whose view has an empty frame; it must be given a frame and run with runModal(for:…) on a window (WebEngine.makePrintOperation / print(in:)). Running it synchronously with run() is reported not to work for web content (known behaviour, not verified here).
  • iOS: UIPrintInteractionController with viewPrintFormatter(). No headers/footers API on either platform beyond WKPreferences.shouldPrintBackgrounds.
  • createPDF captures a rectangle of the document as laid out on screen, not a paginated print rendering.
  • createWebArchiveData contains what WebKit has loaded; resources never fetched (lazy images, blocked frames) are missing. takeSnapshot only captures the visible viewport.
  • Basis: Header; PDF, web archive, snapshot and creation of the print operation — Test. Actually printing — not verified (it would open a print sheet on the owner's Mac).

# 12. Media state, mute, and visibility

  • No public "is playing audio" property and no public page mute on WKWebView (searched the headers: only pauseAllMediaPlayback, setAllMediaPlaybackSuspended, requestMediaPlaybackState and the camera / microphone capture states exist).
  • Fallback: media-state.js watches <audio>/<video> elements from an isolated world and reports playing/audible counts; WebEngine.setMuted mutes those elements, keeps new ones muted, and restores only what it muted. Gaps, by construction: elements never attached to the document (new Audio().play()) and Web Audio (AudioContext) are invisible from an isolated world, so such a tab shows no speaker badge and is not silenced by tab mute. pauseAllMedia() (WebKit's own pauseAllMediaPlayback) is the tool for those.
  • WebKit neither loads nor plays media in a document that is not visible, and delivers getUserMedia requests only to visible documents. A web view that is not in an on-screen window is hidden: prerendered or background-created tabs will not start audio until shown.
  • Basis: absence of API — Header; mute plumbing — Test; hidden-document behaviour — Test (observed: document.hidden === true, networkState stays NO_SOURCE, play() stays pending). Detection of playing audio and the capture permission prompt end to end — not verified (they need a visible window).

# 13. Find in page

  • find(_:configuration:) returns only matchFound. No match count, no index, no "highlight all", no API to clear the highlight. iOS has the system find bar (findInteraction), with its own UI.
  • Fallback: WebEngine.find adds a count computed from the main document's rendered text (sub-frames not counted, capped at 9 999); clearFind removes the selection WebKit left on the last match.
  • Basis: Header (WKFindResult has one property); behaviour — Test.

# 14. Zoom and text size

  • pageZoom (whole-page, reflowing) is public on both platforms; magnification (pinch) on macOS.
  • Text-only zoom has no public API. iOS honours -webkit-text-size-adjust, used by setTextSizePercent; that property is an iOS feature of WebKit, so on macOS the call throws instead of pretending, and the UI must offer page zoom only.
  • Basis: absence of API — Header; the macOS call refusing — Test; the effect of the property on either platform — not verified (iOS code is compiled, not run).

# 15. Desktop / mobile site

  • WKWebpagePreferences.preferredContentMode switches layout heuristics and the user agent on iOS/iPadOS. On macOS there is no mobile mode: WebRuntime sets customUserAgent to an iPhone Safari string for UserAgentMode.mobile. applicationNameForUserAgent is set to Safari's suffix (Version/x Safari/605.1.15) because many sites sniff for it.
  • Basis: Header; user agents actually sent on macOS in each mode — Test.

# 16. Popups and user gestures

  • WebKit does not tell the app whether window.open came from a user gesture (WKNavigationAction has no such public property). With javaScriptCanOpenWindowsAutomatically = false WebKit drops gesture-less popups itself without calling the UI delegate (known behaviour, not verified here), so they could not be counted or offered to the user.
  • Fallback: the setting stays on and WebRuntime applies the policy itself: an isolated-world script reports trusted input events (event.isTrusted), and a window.open within popupActivationWindow (1.5 s) of one is treated as user-initiated. An activated target=_blank link always opens. The site's popups permission overrides: allow opens everything, deny blocks scripted windows even after a click.
  • Limits: the heuristic is time-based, not WebKit's exact transient-activation state; a popup opened after a long asynchronous step following a click is blocked (and listed in blockedPopups, where the user can open it).
  • A child created for window.open must use the configuration WebKit supplies. That configuration shares the opener's WKUserContentController; WebRuntime replaces it so that each tab has its own bridge.
  • Basis: Header; blocked/allowed/permission cases, own controller for the child, window.opener preserved — Test. A real click (trusted event) — not verified (cannot be synthesised through public API).

# 17. Context menus

  • macOS: the only hook is NSView.willOpenMenu(_:with:) on a WKWebView subclass. WebKit gives no description of the clicked element; item identifiers (WKMenuItemIdentifier…) are readable but undocumented. WebRuntime has the page report the element (context-element.js) just before the menu is built.
  • iOS: contextMenuConfigurationFor provides only linkURL (WKContextMenuElementInfo); images and selections get WebKit's default menus. Returning nil shows no menu.
  • Basis: Header; delegate plumbing — Test. A real right-click / long-press — not verified.

# 18. Certificates and TLS

  • The certificate chain of a failed connection is only observable inside the authentication challenge. WebRuntime evaluates the trust there, cancels on failure, and publishes a CertificateError; there is no path to "proceed" except an explicit, in-memory, per-host, per-certificate CertificateException.
  • WKWebView.serverTrust gives the chain of the committed page; no API reports the negotiated TLS version or cipher, certificate transparency, or per-sub-resource chains.
  • HTTPS-only: WKWebpagePreferences.preferredHTTPSNavigationPolicy exists from macOS 15.2 / iOS 18.2 only; the package deploys lower, so the upgrade is done in the navigation policy (one code path on every OS).
  • Basis: Header; invalid certificate end to end with a self-signed TLS fixture, exception binding, HTTPS-only failure and fallback — Test. Expired / wrong-host / revoked certificates on a live connection — not verified end to end (the decision function is unit-tested).

# 19. Processes and lifecycle

  • WKProcessPool is deprecated and ignored since macOS 12 / iOS 15: the app cannot choose which pages share a web content process. Isolation between profiles comes from WKWebsiteDataStore(forIdentifier:).
  • A terminated web content process is reported by webViewWebContentProcessDidTerminate; public API cannot cause or simulate one, nor report its memory use. WebEngine.processState + reload() handle recovery.
  • WKWebsiteDataStore.remove(forIdentifier:) fails with "data store is in use" while any WKWebsiteDataStore object for that identifier is alive, and for a short time after (the network process releases it asynchronously). WebProfileRegistry.deleteStore retries for a few seconds.
  • A WKContentWorld created by name is torn down in the web process when the object is deallocated: globals defined by an earlier evaluation disappear. WebRuntime keeps its world objects for the life of the process.
  • WKUserContentController can only remove all user scripts; UserScriptRegistry re-adds the others. Its userScripts array is a live view: it must be copied before clearing.
  • interactionState is opaque Data; unrecognised data is ignored without error.
  • Basis: Header; all of the above except real process termination — Test. Real termination — not verified (the state handling is tested by invoking the delegate callback).

# Selections and web view lifetime (observed, unexplained)

On macOS 27.0, a WKWebView that is not in a window and whose page holds a selection covering a whole text node / sentence (selection.selectAllChildren(p)) is never deallocated after its last reference is dropped — reproduced with a bare WKWebView, no WebRuntime code involved; a partial-word selection does not trigger it, and clearing the selection, loading a blank page, resigning first responder or hosting the view briefly in an unordered window does not release it. Consequence: the profile's data store stays "in use". Whether the same happens for a view that has been on screen is not verified; if it does, a suspended tab would not free its process. The Blink module should measure this in the running app before relying on suspension for memory.

# 20. Smaller differences worth knowing

Basis for this table: Apple docs / known behaviour, not verified in this repository unless a test is named elsewhere on this page.

Area WKWebView Fallback
Reader mode No API (Safari's Reader is private) reader.js heuristic + native allow-list validation
Page translation, Live Text toggles, Safari AutoFill of passwords/cards Not exposed System AutoFill works in fields; nothing browser-controlled
iCloud Tabs, Safari bookmarks/history Not accessible Own storage and sync
beforeunload confirmation No delegate on either platform Tabs close without the page's prompt
Cookie policy per site WKHTTPCookieStore.setCookiePolicy is store-wide Per-profile only
Intelligent Tracking Prevention On by default, not configurable per site —
Custom schemes WKURLSchemeHandler cannot override http(s), file, about, blob, data orix:// for internal pages only
File uploads macOS: runOpenPanel delegate; iOS: system picker, not customisable —
window.close() Reported only for windows the page opened webEngineDidRequestClose
Files main
Menu

Theme