-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[iOS] Application crashes when processing onCreateWindow #579
Comments
Same issue here, any solution? |
I have same issue. If I implement async and return value, it crash.
if I no return, no crash.
|
Any news on this issue @pichillilorenzo? |
@Alexays I'm not able to reproduce the error. This is my simple test code using the latest version of the plugin: import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isAndroid) {
await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
}
runApp(MaterialApp(
home: MyApp()
));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
InAppWebViewGroupOptions options = InAppWebViewGroupOptions(
crossPlatform: InAppWebViewOptions(
javaScriptCanOpenWindowsAutomatically: true
),
android: AndroidInAppWebViewOptions(
supportMultipleWindows: true,
useHybridComposition: true,
),);
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("On Create Window test")),
body: SafeArea(
child: Column(children: <Widget>[
Expanded(
child: InAppWebView(
initialData: InAppWebViewInitialData(
data: """
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Flutter InAppWebView</title>
</head>
<body>
<a style="margin: 50px; background: #333; color: #fff; font-weight: bold; font-size: 20px; padding: 15px; display: block;"
href="https://flutter.dev"
target="_blank">
Click here to open https://github.com/flutter in a popup!
</a>
</body>
</html>
"""
),
initialOptions: options,
onCreateWindow: (controller, createWindowRequest) async {
print("Window ID is: " + createWindowRequest.windowId.toString());
print(createWindowRequest);
return true;
},
),
),
])),
);
}
} I simply print the request from Can you provide me some code that make it crash? |
@pichillilorenzo In my case it doesn't crash any more on the first click with the latest version but, reclicking on the same link after closing the new window crash the application. |
|
Using my code example, I can click on the link multiple times without any crash. @Alexays could you provide a code example with real links, please? Otherwise I cannot reproduce this error, thanks |
@pichillilorenzo Here's a reproduction of the crash. import 'dart:async';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
Future main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isAndroid) {
await AndroidInAppWebViewController.setWebContentsDebuggingEnabled(true);
}
runApp(MaterialApp(home: MyApp()));
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
InAppWebViewGroupOptions options = InAppWebViewGroupOptions(
crossPlatform:
InAppWebViewOptions(javaScriptCanOpenWindowsAutomatically: true),
android: AndroidInAppWebViewOptions(
supportMultipleWindows: true,
useHybridComposition: true,
),
);
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
void onWebViewCreated(InAppWebViewController controller) async {
await controller.loadData(data: ''''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Flutter InAppWebView</title>
</head>
<body>
<a style="margin: 50px; background: #333; color: #fff; font-weight: bold; font-size: 20px; padding: 15px; display: block;"
href="https://flutter.dev"
target="_blank">
Click here to open https://github.com/flutter in a popup!
</a>
</body>
</html>
''', baseUrl: Uri(scheme: 'https', host: 'localhost'));
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('On Create Window test')),
body: SafeArea(
child: Column(children: <Widget>[
Expanded(
child: InAppWebView(
initialData: InAppWebViewInitialData(
data: '', baseUrl: Uri(scheme: 'https', host: 'localhost')),
initialOptions: options,
onWebViewCreated: onWebViewCreated,
onCreateWindow: (controller, createWindowRequest) async {
print("Window ID is: " + createWindowRequest.windowId.toString());
print(createWindowRequest);
return true;
},
),
),
])),
);
}
} |
@Alexays thanks! I fixed it! It was not related to calling it inside the |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue. |
Environment
Device information:
iPhone 8
Description
Crash application with force unwrap nil exception when processing onCreateWindow
The text was updated successfully, but these errors were encountered: