-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
This crash happens on latest flutter beta 3.10.0-1.1.pre on macOS.
The error message is:
blue_macos[9882:79310701] -[blue_macos.AppDelegate setTerminationHandler:]: unrecognized selector sent to instance 0x6000017348d0
blue_macos[9882:79310701] -[blue_macos.AppDelegate setTerminationHandler:]: unrecognized selector sent to instance 0x6000017348d0
Steps to reproduce
(I also created a repo that can reproduce the crash. See: https://github.com/fertrig/flutter_view_controller_crash)
On macOS:
- Set up a working directory to host a flutter project, a flutter bundle and a macos project:
mkdir flutter_view_controller_crash
mkdir flutter_view_controller_crash/fl_beta
cd flutter_view_controller_crash/fl_beta
// source flutter beta `3.10.0-1.1.pre`
flutter create blue
- Create a flutter bundle from the project you just created
mkdir flutter_view_controller_crash/blue_bundle
cd flutter_view_controller/fl_beta/blue
flutter build bundle -t lib/main.dart --debug --target-platform darwin --asset-dir ../blue_bundle/flutter_assets
-
Create new Xcode project with these details:
- Platform: macOS
- Application: App
- Product Name: blue_macos
- Interface: Storyboard
- Language: Swift
- Create it inside fl_beta directory
-
Once the xcode project is created select blue_macos on the left, then Targets > blue_macos > Signing & Capabilities. Then delete App Sandbox and Hardened Runtime.
-
Copy the
FlutterMacOS.frameworkto blue_macos directory:
cp -R /path/to/flutter-beta-sdk/bin/cache/artifacts/engine/darwin-x64/FlutterMacOS.framework /path/to/flutter_view_controller_crash/fl_beta/blue_macos/
-
In the xcode project, go to Targets > blue_macos> General > Framework, Libraries and Embedded Content. Add FlutterMacOS.framework from fl_beta/blue_macos/FlutterMacOS.framework
-
Replace the contents of AppDelegate.swift with code that uses the bundle to create a
FlutterDartProject, which then callsFlutterViewController.init(FlutterDartProject):
import Cocoa
import FlutterMacOS
@main
class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ aNotification: Notification) {
_launch_1()
}
func applicationWillTerminate(_ aNotification: Notification) {
}
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
return true
}
func _launch_1() {
let bundleUrl = URL(fileURLWithPath: "/PATH/TO/blue_bundle") // replace with your path
let bundle = Bundle.init(path: bundleUrl.path)
let project = FlutterDartProject.init(precompiledDartBundle: bundle)
let controller = FlutterViewController.init(project: project) // set your breakpoint here
let window = NSWindow()
window.contentViewController = controller
let windowController = NSWindowController()
windowController.contentViewController = window.contentViewController
window.setContentSize(NSSize(width: 300, height: 400))
window.setFrameOrigin(NSPoint(x: 100.0, y: 100.0))
window.title = "blue"
windowController.window = window
windowController.showWindow(self)
}
}- Run the app from xcode, and notice the error message:
blue_macos[9882:79310701] -[blue_macos.AppDelegate setTerminationHandler:]: unrecognized selector sent to instance 0x6000017348d0
blue_macos[9882:79310701] -[blue_macos.AppDelegate setTerminationHandler:]: unrecognized selector sent to instance 0x6000017348d0
The error message is emitted when calling FlutterViewController.init(project: project) above. It also crashes the control flow. The flutter window does not show.
If you run the same steps with flutter stable, it doesn't crash, and the flutter window shows with the flutter demo app.
I created this repo if you need help setting things up: https://github.com/fertrig/flutter_view_controller_crash
flutter doctor -v
[✓] Flutter (Channel beta, 3.10.0-1.1.pre, on macOS 12.6.2 21G320 darwin-x64, locale en-US)
• Flutter version 3.10.0-1.1.pre on channel beta at /Users/fertrig/development/flutter-sdks/beta-channel
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ecdb7841df (2 days ago), 2023-04-11 20:47:40 -0700
• Engine revision 870e640e7e
• Dart version 3.0.0 (build 3.0.0-417.1.beta)
• DevTools version 2.23.1
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/fertrig/Library/Android/sdk
✗ cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[!] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
! CocoaPods 1.10.0 out of date (1.11.0 is recommended).
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To upgrade see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.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.13+0-b1751.21-8125866)
[✓] VS Code (version 1.76.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.60.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 12.6.2 21G320 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.49
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 2 categories.