-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[MacOS Intel] callAsyncJavaScript
causes the entire app to crash
#2619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @sbis04, thanks a lot for reporting this issue. My teammate and I tried to reproduce this issue but were unable to do so. Below, I share the source code used to reproduce the issue and recordings.
Source Codeimport 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
void main() {
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: WebViewScreen(),
),
);
}
}
class WebViewScreen extends StatefulWidget {
const WebViewScreen({super.key});
@override
State<WebViewScreen> createState() => _WebViewScreenState();
}
class _WebViewScreenState extends State<WebViewScreen> {
final _settings = InAppWebViewSettings(isInspectable: kDebugMode);
final _isCreated = ValueNotifier(false);
InAppWebViewController? _webViewController;
@override
void dispose() {
_isCreated.dispose();
_webViewController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(15),
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 500, maxHeight: 500),
child: InAppWebView(
initialUrlRequest: URLRequest(
url: WebUri('https://flutter.dev'),
),
initialSettings: _settings,
onWebViewCreated: (controller) {
_isCreated.value = true;
_webViewController = controller;
},
onConsoleMessage: (controller, consoleMessage) {
if (kDebugMode) {
print(consoleMessage);
}
},
),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 15),
child: ValueListenableBuilder(
valueListenable: _isCreated,
builder: (context, isLoaded, _) {
return ElevatedButton(
onPressed: isLoaded ? _callAsyncJavaScript : null,
child: Text('callAsyncJavaScript'),
);
}),
),
],
),
],
);
}
Future<void> _callAsyncJavaScript() async {
final result = await _webViewController!.callAsyncJavaScript(
functionBody: '''
var p = new Promise(resolve => window.setTimeout(() => resolve(x), 2000));
await p;
return p;
''',
arguments: {'x': 123456},
);
print('RESULT: ${result?.value} (${result?.value?.runtimeType})');
}
}
Device specs and tools
Could you please share the minimal reproducible example that causes the crash on your side? |
@ksokolovskyi Sorry, I missed a very important info, this is only reproducible in the release build (debug mode works just fine). |
@sbis04, thanks a lot for that information! |
Hi @sbis04, my teammate with an Intel Mac tried the sample again in the release mode, and the crash didn't happen. release_mode_intel.mov |
Hi @ksokolovskyi, I tested your sample code on my machine, and the app is crashing even in debug mode. Here’s my setup:
Crash Log
2025-06-04.03-49-33.mp4 |
Just a quick update. I tested the app on the iOS 18.0 simulator, and it works fine there. Seems like the issue might be specific to certain iOS versions. |
My situation is "the app compiled by iOS 18.5 platform will crash in 18.1, 17.6 and 17.5 emulator and real machine." And I resolve the problem by change callAsyncJavaScript to evaluateJavascript. It's weird |
Uh oh!
There was an error while loading. Please reload this page.
Is there an existing issue for this?
Current Behavior
Using
callAsyncJavaScript
causes the entire app to crash. But this just happens on the Intel-based macOS systems, works fine on macOS with Apple Silicon and Windows systems.NOTE: This is only reproducible on the release build (debug mode works just fine).
Expected Behavior
The
callAsyncJavaScript
method should work on Intel-based macOS systems.Steps with code example to reproduce
Steps with code example to reproduce
// Paste your code here
Stacktrace/Logs
MacOS Crash Stacktrace
Flutter version
3.27.3
Operating System, Device-specific and/or Tool
Hardware:
MacBook Pro (16 inch, 2019)
2.6 GHz 6-Core Intel Core i7
Operating System
macOS Ventura (Version 13.7.5)
Plugin version
6.1.5
Additional information
No response
Self grab
The text was updated successfully, but these errors were encountered: