-
Notifications
You must be signed in to change notification settings - Fork 29.1k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 2.2Found to occur in 2.2Found to occur in 2.2found in release: 2.5Found to occur in 2.5Found to occur in 2.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: webviewThe WebView pluginThe WebView pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Steps to Reproduce
Expected results:
flutter: JavascriptMessage: User Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 12_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
Actual results:
flutter: JavascriptMessage: User Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148
[VERBOSE-2:ui_dart_state.cc(166)] Unhandled Exception: PlatformException(evaluateJavaScript_failed, Failed evaluating JavaScript, JavaScript string was: 'Toaster.postMessage("User Agent: " + navigator.userAgent);'
Error Domain=WKErrorDomain Code=5 "JavaScript execution returned a result of an unsupported type" UserInfo={NSLocalizedDescription=JavaScript execution returned a result of an unsupported type})
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:572:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:161:18)
<asynchronous suspension>
#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:334:12)
#3 MethodChannelWebViewPlatform.evaluateJavascript (package:webview_flutter/src/webview_method_channel.dart:115:21)
#4 WebViewController.evaluateJavascript (package:webview_flutter/webview_flutter.dart:672:39)
#5 MyApp.build.<anonymous closure> (package:bug/main.dart:38:27)<…>
Logs
[✓] Flutter (Channel stable, 1.20.4, on Mac OS X 10.15.6 19G2021, locale
zh-Hans-CN)
• Flutter version 1.20.4 at /Users/rxlyc/src/flutter
• Framework revision fba99f6cf9 (7 days ago), 2020-09-14 15:32:52 -0700
• Engine revision d1bc06f032
• Dart version 2.9.2
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
If the Android SDK has been installed to a custom location, set
ANDROID_SDK_ROOT to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
• CocoaPods version 1.9.3
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
[✓] IntelliJ IDEA Community Edition (version 2020.2.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin version 49.0.4
• Dart plugin version 202.7319.5
[✓] Connected device (3 available)
• iPhone 11 (mobile) • 0777B517-027C-4F79-8983-7EA4F7E5BCB5 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-14-0 (simulator)
• iPhone X (mobile) • BDE9BF21-244B-4DF2-BDC5-9E67267E2CE9 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)
ios/Runner/Info.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>bug</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>io.flutter.embedded_views_preview</key>
<string>YES</string>
</dict>
</plist>
pubspec.yaml:
...
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
webview_flutter: any
...
lib/main.dart:
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
WebViewController _controller;
JavascriptChannel _toasterJavascriptChannel(BuildContext context) {
return JavascriptChannel(
name: 'Toaster',
onMessageReceived: (JavascriptMessage message) {
print('JavascriptMessage: ${message.message}');
},
);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('JavascriptChannels'),),
body: Container(
child: WebView(
initialUrl: 'https://www.google.com',
javascriptMode: JavascriptMode.unrestricted,
javascriptChannels: [_toasterJavascriptChannel(context)].toSet(),
onWebViewCreated: (WebViewController container) {
_controller = container;
},
onPageFinished: (url) {
_controller.evaluateJavascript('Toaster.postMessage("User Agent: " + navigator.userAgent);');
},
),
),
),
);
}
}
mertcanbs, mtsrdr and VictorUvarov
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listc: crashStack traces logged to the consoleStack traces logged to the consolefound in release: 2.2Found to occur in 2.2Found to occur in 2.2found in release: 2.5Found to occur in 2.5Found to occur in 2.5has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: webviewThe WebView pluginThe WebView pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-iosiOS applications specificallyiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version