I have a Flutter app using flutter_inappwebview: ^6.1.0. The frontend is built in Flutter, and the backend is Spring Boot (Java).
In the Flutter app, I load a WebView using initialUrlRequest, pointing to a React-based webpage (form.tsx). The React page tries to dynamically load a JavaScript file via an API endpoint, then notifies Flutter when it's rendered.
React code(form.tsx)
const script: HTMLScriptElement = document.createElement('script');
script.src = formScriptUrl; // loaded via axios blob: "/down?formPath=/resources/example/form-ex.js"
script.defer = true;
script.onload = function () {
window.flutter_inappwebview.callHandler('formRendered');
};
document.body.appendChild(script);
The JS file is fetched from a Spring API:
return await axios( {
url: '/down?formPath=/resources/example/form-ex.js',
method: 'GET',
responseType: 'blob',
headers: {
'Content-Type': 'text/javascript'
'Accept': 'application/json',
},
});
Once the formRendered signal is received in Flutter, we run this:
await _webViewController?.evaluateJavascript(source: 'getBodyHtml()');
Where getBodyHtml() is:
const formEl = document.getElementById("body-html-area");
const BodyHtml = formEl?.innerHTML || '';
return BodyHtml;
Problem:
- No API call is made to /down?formPath=.... The server has no request or error logs.
- We wrapped the script logic in try-catch, with an alert() in case of errors — but no alert shows.
- The WebView just shows a blank screen.
- This issue occurs only for 2~3 users. Most users have no problems.
- Devices include both Android and iOS.
- Minimum Android version observed: 14
- No consistent pattern (e.g., Galaxy S23 works for some, fails for others)
What I've tried:
- Confirmed the JS file loads fine when accessed directly in browsers.
- Confirmed window.flutter_inappwebview.callHandler() works for most users.
- Verified getBodyHtml() works in normal conditions.
- Confirmed correct MIME type (text/javascript) and response format (blob).
- Added alert() statements in the script load path — but nothing is triggered for affected users.
- No CORS error is shown (and most users work fine, so it shouldn't be a policy issue).
What could cause this script loading to silently fail on only a few devices?
Is there something about how blobs, script injection, or WebView caching works differently on a few devices or under rare network conditions?