-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 2.8Found to occur in 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9Found to occur in 2.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team
Description
Steps to Reproduce
- flutter create bug
- copy first code sample to
bug/lib/main.dart - copy second code sample to
bug/ios/Runner/AppDelegate.swift - open project in XCode and set IOS Deployment Target to 10.0
- flutter run
Expected results:
The native-to-flutter call should be buffered and carried out as soon as the Flutter side is ready. The log should contain "Flutter side received method call: qux".
Actual results:
The method is not called. The inverse flutter-to-native call works as expected and the corresponding log message appears in the log.
The documentation for FlutterMethodChannel.resizeBuffer states:
Adjusts the number of messages that will get buffered when sending messages to channels that aren’t fully set up yet.
For example, the engine isn’t running yet or the channel’s message handler isn’t set up on the Dart side yet.
Code sample
bug/lib/main.dart
import 'dart:developer' as developer;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<StatefulWidget> createState() => MyAppState();
}
class MyAppState extends State<MyApp> {
static const _methodChannel = MethodChannel('com.example/foo');
MyAppState() {
_methodChannel.setMethodCallHandler((call) async {
developer.log('Flutter side received method call: ${call.method}');
});
_methodChannel.invokeMethod('bar');
}
@override
Widget build(BuildContext context) {
return const MaterialApp(home: Scaffold());
}
}bug/ios/Runner/AppDelegate.swift
import UIKit
import Flutter
import os
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
GeneratedPluginRegistrant.register(with: self)
let controller = self.window?.rootViewController as! FlutterViewController
let methodChannel = FlutterMethodChannel(name: "com.example/foo", binaryMessenger: controller.binaryMessenger)
methodChannel.resizeBuffer(256)
methodChannel.setMethodCallHandler() { call, result in
os_log("Native side received method call: %s", call.method)
result(nil)
}
methodChannel.invokeMethod("qux", arguments: nil)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}Logs
[ +209 ms] com.example.bug: 19613
[ ] Waiting for observatory port to be available...
[ +699 ms] Observatory URL on device: http://127.0.0.1:58364/0q0pgsZkxEY=/
[ +14 ms] Caching compiled dill
[ +110 ms] Connecting to service protocol: http://127.0.0.1:58364/0q0pgsZkxEY=/
[ +201 ms] Native side received method call: bar
[ +63 ms] Launching a Dart Developer Service (DDS) instance at http://127.0.0.1:0, connecting to VM service at http://127.0.0.1:58364/0q0pgsZkxEY=/.
[ +106 ms] DDS is listening at http://127.0.0.1:58367/yFaUD6jPm2k=/.
[ +76 ms] Successfully connected to service protocol: http://127.0.0.1:58364/0q0pgsZkxEY=/
[ +34 ms] DevFS: Creating new filesystem on the device (null)
[ +23 ms] DevFS: Created new filesystem on the device (file:///Users/user/Library/Developer/CoreSimulator/Devices/E5F8DBC3-FA2A-460B-B0C0-D8FC99E8E34B/data/Containers/Data/Application/FC663638-5E91-4239-BC5D-B8E1EF27FF5A/tmp/bugUWqHtw/bug/)
[ +2 ms] Updating assets
[ +88 ms] Syncing files to device iPhone 11...
[ +1 ms] <- reset
[ ] Compiling dart to kernel with 0 updated files
[ +2 ms] <- recompile package:bug/main.dart e22d5742-126e-4e24-b89b-d53bce342ebd
[ ] <- e22d5742-126e-4e24-b89b-d53bce342ebd
[ +88 ms] Updating files.
[ ] DevFS: Sync finished
[ ] Syncing files to device iPhone 11... (completed in 94ms)
[ ] Synced 0.0MB.
[ +2 ms] <- accept
[ +3 ms] Connected to _flutterView/0x7fce31829e20.
[ +3 ms] Flutter run key commands.
[ +1 ms] r Hot reload. 🔥🔥🔥
[ ] R Hot restart.
[ ] h List all available interactive commands.
[ ] d Detach (terminate "flutter run" but leave application running).
[ ] c Clear the screen
[ ] q Quit (terminate the application on the device).
[ ] 💪 Running with sound null safety 💪
[ +1 ms] An Observatory debugger and profiler on iPhone 11 is available at: http://127.0.0.1:58367/yFaUD6jPm2k=/
[ +212 ms] The Flutter DevTools debugger and profiler on iPhone 11 is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:58367/yFaUD6jPm2k=/
Analyzing bug...
No issues found! (ran in 2.3s)
[✓] Flutter (Channel stable, 2.8.0, on macOS 12.0.1 21A559 darwin-x64, locale en-DE)
• Flutter version 2.8.0 at /usr/local/Caskroom/flutter/2.8.0/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cf44000065 (13 days ago), 2021-12-08 14:06:50 -0800
• Engine revision 40a99c5951
• Dart version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/user/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /Users/user/Library/Android
• ANDROID_SDK_ROOT = /Users/user/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
[✓] VS Code (version 1.59.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (3 available)
• iPhone 11 (mobile) • E5F8DBC3-FA2A-460B-B0C0-D8FC99E8E34B • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
• macOS (desktop) • macos • darwin-x64 • macOS 12.0.1 21A559 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.110
• No issues found!
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: platform-viewsEmbedding Android/iOS views in Flutter appsEmbedding Android/iOS views in Flutter appsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 2.8Found to occur in 2.8Found to occur in 2.8found in release: 2.9Found to occur in 2.9Found to occur in 2.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyiOS applications specificallyteam-iosOwned by iOS platform teamOwned by iOS platform teamtriaged-iosTriaged by iOS platform teamTriaged by iOS platform team