Skip to content

fix: prevent iOS WKWebView JS throttling from zero-area frame#100

Closed
panosinthezone wants to merge 1 commit into
mainfrom
devin/1780354989-fix-wkwebview-ios-visibility-throttling
Closed

fix: prevent iOS WKWebView JS throttling from zero-area frame#100
panosinthezone wants to merge 1 commit into
mainfrom
devin/1780354989-fix-wkwebview-ios-visibility-throttling

Conversation

@panosinthezone

Copy link
Copy Markdown

Summary

Port of crossmint-sdk#1878 — same root cause, same fix, different platform.

A WKWebView(frame: .zero, ...) causes WebKit to clear ActivityState::IsVisible, which triggers updateThrottleState()dropVisibleActivity() — the WebContent process loses its foreground assertion and becomes eligible for suspension, timer throttling, and priority termination under memory pressure.

Changes:

  • CrossmintWebView.swift: WKWebView(frame: .zero, ...)WKWebView(frame: CGRect(x: 0, y: 0, width: 1, height: 1), ...) so the backing layer is composited from creation
  • View+NonCustodialSigner.swift: .frame(width: 20, height: 20).frame(width: 1, height: 1) + .opacity(0) — the previous 20×20 was unnecessary padding; a 1×1 composited layer is sufficient, and .opacity(0) ensures the view is truly invisible while keeping iOS's visibility flag set

WebKit source references: see detailed walkthrough.

Link to Devin session: https://crossmint.devinenterprise.com/sessions/aa42293821a24fee86c25e350715efd5
Requested by: @panosinthezone

Change WKWebView initial frame from .zero to 1x1 so iOS considers
the WebView composited from creation and does not clear
ActivityState::IsVisible.

Add .opacity(0) to HiddenEmailSignersView so the WebView is truly
invisible but remains composited — matching the approach used in
the React Native SDK (crossmint-sdk#1878).

Co-Authored-By: Panayiotis Halios <panos@paella.dev>
@devin-ai-integration

Copy link
Copy Markdown
Contributor
Original prompt from Panayiotis

#``# Context

In the Crossmint React Native wallets SDK, a hidden WKWebView is used to communicate with a signer relay (TEE). The WebView is rendered in:

Repository: Crossmint/crossmint-sdk
File: packages/client/ui/react-native/src/providers/CrossmintWalletProvider.tsx

Currently, the WebView is hidden using:

  • A parent &lt;View&gt; with position: "absolute", width: 0, height: 0, overflow: "hidden" (lines 422-430)
  • The &lt;RNWebView&gt; itself styled at width: 1, height: 1 (lines 481-484)

The wrapper component is at:
File: packages/client/rn-window/src/rn-webview/RNWebView.tsx (lines 142-153)

On iOS, the WebView sometimes fails to execute or pull JS code. There are already multiple recovery mechanisms (content process termination handling at lines 443-461, eager handshake at lines 249-272, handshake retry with reload), but the root cause is not well understood.

#``# Task

#``#``# Step 1: Research Apple's official WKWebView documentation

Search Apple's developer documentation (developer.apple.com) and WebKit source code/bug trackers for authoritative answers to these specific questions:

  1. Does WKWebView throttle or suspend JavaScript execution when the view has zero visible area? Look for documentation on WKWebView process lifecycle, specifically whether the WebContent process behavior changes based on the view's frame size, visibility, or whether it's clipped by a parent view with overflow: hidden and zero dimensions.

  2. What triggers webViewWebContentProcessDidTerminate:? Find the exact documented conditions. Is it only memory pressure? Does view visibility/size factor into the priority heuristic for which WebContent processes get terminated first?

  3. Does iOS treat a 0x0 clipped WKWebView differently from a 1x1 visible one? Specifically, does the compositing/rendering layer report the view as "not visible" to the system, and does that affect the WebContent process priority?

  4. **Are there any documented WKWebViewConfiguration... (3139 chars truncated...)

@devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "fix: prevent iOS WKWebView JS throttling..." | Re-trigger Greptile

@panosinthezone panosinthezone deleted the devin/1780354989-fix-wkwebview-ios-visibility-throttling branch June 2, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant