go-flutter-desktop / go-flutter

Flutter on Windows, MacOS and Linux - based on Flutter Embedding, Go and GLFW.
https://hover.build/
BSD 3-Clause "New" or "Revised" License
5.87k stars 283 forks source link

Call Dart from Golang crashes in debug mode #529

Closed mapleafgo closed 4 years ago

mapleafgo commented 4 years ago

Hover doctor

$ hover doctor
hover: Hover version v0.44.0 running on windows
hover: Sharing flutter version
Flutter 1.22.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 84f3d28555 (13 days ago) • 2020-10-15 16:26:19 -0700
Engine • revision b8752bbfff
Tools • Dart 2.10.2
hover: Flutter engine commit: https://github.com/flutter/engine/commit/b8752bbfff0419c8bf616b602bc59fd28f6a3d1b
hover: ⚠ The go-flutter project tries to stay compatible with the beta channel of Flutter.
hover: ⚠     It's advised to use the beta channel: `flutter channel beta`
hover: Finding out the C compiler version
gcc (Rev2, Built by MSYS2 project) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

hover: Sharing the content of go.mod
module go_flutter_systray_example/go

go 1.15

require (
        github.com/fanlide/go-flutter-systray/go v0.0.0-00010101000000-000000000000
        github.com/go-flutter-desktop/go-flutter v0.42.0
        github.com/pkg/errors v0.9.1
)

replace github.com/fanlide/go-flutter-systray/go => ..\..\go
hover: Sharing the content of hover.yaml
application-name: ""
executable-name: ""
package-name: ""
license: ""
target: lib/main_desktop.dart
branch: ""
cache-path: ""
opengl: ""
engine-version: ""
hover: Sharing the content of go/cmd
go\cmd\import-go_flutter_systray-plugin.go      go\cmd\main.go  go\cmd\options.go

Error output

When I run a program using hover run, calling dart from golang in the way shown in the example will crash, but not when hover build windows is packaged error:

[FATAL:..\flutter/fml/memory/weak_ptr.h(122)] Check failed: (checker_.checker).IsCreationThreadCurrent().
Lost connection to device.
hover: App 'go_flutter_systray_example' exited with error: exit status 3
pchampio commented 4 years ago

Please check https://github.com/JanezStupar/flutter_systray for a systray plugin More information about correct thread handling can be found in: https://github.com/go-flutter-desktop/go-flutter/issues/444

Still go-flutter shouldn't put the embedder in a Check failed status. This will have to be investigated in the future.

pchampio commented 4 years ago

Maybe https://github.com/go-flutter-desktop/go-flutter/blob/master/messenger.go#L58 and https://github.com/go-flutter-desktop/go-flutter/blob/master/messenger.go#L74 should be called in the same manner as: https://github.com/go-flutter-desktop/go-flutter/blob/master/messenger.go#L130

mapleafgo commented 4 years ago

@pchampio I tried https://github.com/JanezStupar/flutter_systray/tree/master/example too

pchampio commented 4 years ago

And you have the same results? Did you modify JanezStupar/flutter_systray ? Could you create a simple plugin (without) systray that reproduce this issue ? Thanks

mapleafgo commented 4 years ago

I tried the example of JanezStupar/Ffltter_Systray and got the same result.

The fanlide/go-flutter-systray is plugin I wrote. It's not based on JanezStupar/Ffltter_Systray modification.

You can hover run to run their examples, and they all have this problem when they click on the menu.

mapleafgo commented 4 years ago

@pchampio I'm sure hover build windows won't have this problem because I'm already using fanlide/go-flutter-systray. But this somewhat affects the development.

pchampio commented 4 years ago

Does: hover run -b '@fix/call_dart_from_go' fixes this issue ?

mapleafgo commented 4 years ago

Does: hover run -b '@fix/call_dart_from_go' fixes this issue ?

Testing it can fixes this issue.

pchampio commented 4 years ago

Will be available in next tag. You can use hover run -b '@master' while waiting.

mapleafgo commented 4 years ago

Will be available in next tag. You can use hover run -b '@master' while waiting.

OK,Thanks