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:
- HTML Loading: The HTML page is successfully parsed and rendered, showing the initial state:
ReactNativeWebView: checking...
- JavaScript Execution Failure: The script block within the HTML fails to execute entirely. The interval loop which updates the status never runs.
- 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.
- 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.
Description
On Android release builds, the
RichTextEditorcomponent (which renders aWebViewcontaining acontenteditableeditor 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 viapostMessage.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
./gradlew assembleRelease/ signed APK)13.15.0Behavior Details & Debugging Steps Taken
We set up a debug banner inside the WebView's HTML (
<div id="debug-log">) to trace the execution:ReactNativeWebView: checking...injectedJavaScript: Extracted the script intoinjectedJavaScriptto run via native JavaevaluateJavascript()engine.injectedJavaScriptBeforeContentLoaded+DOMContentLoaded: Registered the JS before content loaded to bypass race conditions.//), and avoided declaring functions inside block statements (liketry {}) which causes syntax errors in older WebViews.baseUrl="file:///android_asset/", disablingincognitomode on Android, and enabling file access settings.baseUrl), script execution remains blocked or silent on release builds, suggesting a Chromium WebView sandbox or security origin restriction.Suggested Solutions / Avenues of Investigation
chrome://inspect) on a release build withWebView.setWebContentsDebuggingEnabled(true)enabled inMainActivity.