Skip to content

[Bug]: RichTextEditor WebView script execution blocks / postMessage fails on Android release builds #19

Description

@arnauda-gh

Description

On Android release builds, the RichTextEditor component (which renders a WebView containing a contenteditable editor for composing email bodies) fails to execute its JavaScript script. This prevents the user's typed input from syncing back to the React Native parent component via postMessage.

Consequently, the "Send" button remains disabled because the parent component thinks the email body is empty.

(Note: This issue was compiled and structured by an AI coding assistant during an interactive debugging session).

Environment

  • Platform: Android
  • Build Type: Release Build (./gradlew assembleRelease / signed APK)
  • React Native WebView version: 13.15.0
  • Device tested: SM-G996U1 (Android 14)

Behavior Details & Debugging Steps Taken

We set up a debug banner inside the WebView's HTML (<div id="debug-log">) to trace the execution:

  1. HTML Loading: The HTML page is successfully parsed and rendered, showing the initial state: ReactNativeWebView: checking...
  2. JavaScript Execution Failure: The script block within the HTML fails to execute entirely. The interval loop which updates the status never runs.
  3. Attempted Bypass Methods:
    • injectedJavaScript: Extracted the script into injectedJavaScript to run via native Java evaluateJavascript() engine.
    • injectedJavaScriptBeforeContentLoaded + DOMContentLoaded: Registered the JS before content loaded to bypass race conditions.
    • Cleaning syntax: Made sure the script strictly complies with ES5, removed single-line comments (//), and avoided declaring functions inside block statements (like try {}) which causes syntax errors in older WebViews.
    • WebView Props: Tested removing baseUrl="file:///android_asset/", disabling incognito mode on Android, and enabling file access settings.
  4. Outcome: Even with a clean inline script and the default data origin (without baseUrl), script execution remains blocked or silent on release builds, suggesting a Chromium WebView sandbox or security origin restriction.

Suggested Solutions / Avenues of Investigation

  • Inspect with Chrome Remote Debugging (chrome://inspect) on a release build with WebView.setWebContentsDebuggingEnabled(true) enabled in MainActivity.
  • Investigate alternative rich text editors or native components if local WebView inline scripts continue to be blocked by security/local resource policies in production Android environments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions