react / react/react-native

<Activity mode="hidden"> prevents WKWebView from loading content (onLoad never fires)

Ouverte
#56,180 1 commentaire 1 réaction 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Component: WebView Needs: Triage :mag: Stale
Langage dominant
C++
Étoiles
127k
Forks
25.3k
Merge moyen
1 j 23 h
PR mergées (30 j)
4

Description

Description

A WKWebView (via react-native-webview) inside never loads its content. onLoad/onLoadStart/onLoadEnd never fire. This makes Activity unusable for pre-rendering/pooling WebViews offscreen.

Activity mode="hidden" applies display: none via cloneHiddenInstance() in Fabric, which maps to UIView.hidden = YES + Yoga zeroing the frame. WKWebView requires a non-zero frame and visible state to initialize its Web Content process and load content.

Also produces this warning as the web content process gets jetsammed:
[BrowserEngineKit] Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 NSUnderlyingError: RBSRequestErrorDomain Code=3 "No such process found"

WebView pooling — pre-render WebViews in Activity mode="hidden", then flip to mode="visible" for instant display. Currently impossible because content never loads while hidden.

Versions

  • react-native: 0.83.2
  • react: 19.2.0
  • react-native-webview: 13.16.0
Steps to reproduce

Minimal Reproducible Example:

  import { useState, useCallback, Activity } from "react";
  import { View, Text, StyleSheet } from "react-native";
  import { WebView } from "react-native-webview";

  const HTML = `<!DOCTYPE html><html><body><h1>Hello</h1></body></html>`;

  export default function Test() {
    const [logs, setLogs] = useState<string[]>([]);
    const log = useCallback((msg: string) => {
      console.log(msg);
      setLogs((p) => [msg, ...p]);
    }, []);

    return (
      <View style={{ flex: 1, padding: 20 }}>
        {/* ✅ This fires onLoad */}
        <Activity mode="visible">
          <View style={{ width: 1, height: 1, overflow: "hidden" }}>
            <WebView source={{ html: HTML }} onLoad={() => log("VISIBLE: onLoad ✅")} />
          </View>
        </Activity>

        {/* ❌ This never fires onLoad */}
        <Activity mode="hidden">
          <View style={{ width: 1, height: 1, overflow: "hidden" }}>
            <WebView source={{ html: HTML }} onLoad={() => log("HIDDEN: onLoad ❌")} />
          </View>
        </Activity>

        {/* ✅ Control without Activity */}
        <View style={{ width: 1, height: 1, overflow: "hidden" }}>
          <WebView source={{ html: HTML }} onLoad={() => log("CONTROL: onLoad ✅")} />
        </View>

        {logs.map((l, i) => <Text key={i}>{l}</Text>)}
      </View>
    );
  }

Only VISIBLE and CONTROL log. HIDDEN never fires any load events.

React Native Version

0.83.2

Affected Platforms

Runtime - iOS

Output of npx @react-native-community/cli info
info Fetching system and libraries information...
System:
  OS: macOS 15.6.1
  CPU: (10) arm64 Apple M1 Pro
  Memory: 128.64 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 23.2.0
    path: /Users/mark/.nvm/versions/node/v23.2.0/bin/node
  Yarn:
    version: 1.22.22
    path: /Users/mark/.nvm/versions/node/v23.2.0/bin/yarn
  npm:
    version: 10.9.0
    path: /Users/mark/.nvm/versions/node/v23.2.0/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.2
      - iOS 26.2
      - macOS 26.2
      - tvOS 26.2
      - visionOS 26.2
      - watchOS 26.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2025.2 AI-252.27397.103.2522.14617522
  Xcode:
    version: 26.2/17C52
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 23.0.2
    path: /opt/homebrew/opt/openjdk/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 19.2.0
    wanted: 19.2.0
  react-native:
    installed: 0.83.2
    wanted: 0.83.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

info React Native v0.84.1 is now available (your project is running on v0.83.2).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.84.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.83.2&to=0.84.1
info For mor
Stacktrace or Logs
[BrowserEngineKit] Failed to terminate process: Error Domain=com.apple.extensionKit.errorDomain Code=18 NSUnderlyingError: RBSRequestErrorDomain Code=3 "No such process found"
MANDATORY Reproducer

https://snack.expo.dev/@markwitt/ab3289

Screenshots and Videos

No response

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par le comportement de cloneHiddenInstance() dans Fabric et reproduisez le problème à l’aide du Snack lié et de l’exemple minimal. Vérifiez le correctif avec les WebViews visible, masquée et de contrôle ; le travail est terminé lorsque la WKWebView masquée charge du contenu et que ses callbacks onLoad, onLoadStart et onLoadEnd sont déclenchés.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
ios, react-native, typescript
Domaine
mobile-dev
Type d'issue
Bug
Difficulté
4/5
Temps estimé
3-5 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
50/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.