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

FormatUnavailable: Win32: Failed to convert clipboard to string: #537

Closed itMicmouse closed 3 years ago

itMicmouse commented 3 years ago

Hover doctor

$ hover doctor
hover: Hover version v0.45.0 running on windows
hover: Sharing packaging tools
hover: darwin-bundle is supported
hover: Packaging darwin-dmg is not supported on windows
hover: To still package darwin-dmg on windows you need to run hover with the `--docker` flag.
hover: Packaging darwin-pkg is not supported on windows
hover: To still package darwin-pkg on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-appimage is not supported on windows
hover: To still package linux-appimage on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-deb is not supported on windows
hover: To still package linux-deb on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-pkg is not supported on windows
hover: To still package linux-pkg on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-rpm is not supported on windows
hover: To still package linux-rpm on windows you need to run hover with the `--docker` flag.
hover: Packaging linux-snap is not supported on windows
hover: To still package linux-snap on windows you need to run hover with the `--docker` flag.
hover: To package windows-msi these tools are required: candle
hover: Install the WiX Toolset from https://wixtoolset.org/releases/
hover: To still package windows-msi without the required tools installed you need to run hover with the `--docker` flag.
hover: 
hover: Sharing flutter version
Flutter 1.23.0-18.1.pre • channel beta • https://github.com/flutter/flutter.git
Framework • revision 198df796aa (4 weeks ago) • 2020-10-15 12:04:33 -0700
Engine • revision 1d12d82d9c
Tools • Dart 2.11.0 (build 2.11.0-213.1.beta)
hover: Flutter engine commit: https://github.com/flutter/engine/commit/1d12d82d9cb54876f58044aa52198d53ec841c3d
hover: Finding out the C compiler version
gcc (tdm64-1) 9.2.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 github.com/my-organization/simpleApplication/go

go 1.13

require (
        github.com/atotto/clipboard v0.1.2
        github.com/denisbrodbeck/machineid v1.0.1
        github.com/go-flutter-desktop/go-flutter v0.42.0
        github.com/go-flutter-desktop/plugins/package_info v0.0.0-20191107105320-39f89c3e8eca
        github.com/go-flutter-desktop/plugins/path_provider v0.3.3
        github.com/go-flutter-desktop/plugins/shared_preferences v0.4.3
        github.com/go-flutter-desktop/plugins/url_launcher v0.1.2
        github.com/go-gl/glfw v0.0.0-20191125211704-12ad95a8df72
        github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200707082815-5321531c36a2
        github.com/pkg/errors v0.9.1
        golang.org/x/text v0.3.3
)
hover: Sharing the content of hover.yaml
application-name: ""
executable-name: ""
package-name: ""
license: ""
target: lib/main_test.dart
branch: ""
cache-path: ""
opengl: none
engine-version: ""
hover: Sharing the content of go/cmd

Error output

Using hover build [...] --XXX to build my application, I get the following error:

GLFW: An invalid error was not accepted by the caller: FormatUnavailable: Win32: Failed to convert clipboard to string: 操作成功完成。
GLFW: Please report this bug in the Go package immediately.
panic: FormatUnavailable: Win32: Failed to convert clipboard to string: 操作成功完成。

goroutine 17 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError(0x0, 0x0, 0x0, 0xc0000050c0, 0x0)
        C:/Users/yangyakun/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:178 +0x208
github.com/go-gl/glfw/v3.3/glfw.panicError(...)
        C:/Users/yangyakun/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:185
github.com/go-gl/glfw/v3.3/glfw.PostEmptyEvent()
        C:/Users/yangyakun/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/window.go:1007 +0x3f
github.com/go-flutter-desktop/go-flutter.(*EventLoop).PostTask(0xc0000a7470, 0xe308570, 0x7ff9a213c900, 0x21255b1fd1a4)
        C:/Users/yangyakun/go/pkg/mod/github.com/go-flutter-desktop/go-flutter@v0.42.0/event-loop.go:73 +0x139
github.com/go-flutter-desktop/go-flutter/embedder.proxy_post_task_callback(...)
        C:/Users/yangyakun/go/pkg/mod/github.com/go-flutter-desktop/go-flutter@v0.42.0/embedder/embedder_proxy.go:94
github.com/go-flutter-desktop/go-flutter/embedder._cgoexpwrap_1d54f1096e3c_proxy_post_task_callback(0xe308570, 0x7ff9a213c900, 0x21255b1fd1a4, 0xc00000a528)
        _cgo_gotypes.go:906 +0x53
hover: App 'saas_clinicsys' exited with error: exit status 2

When I turn on the computer(windows 10) Problems will happen if I use Ctrl+c this problem not happen

pchampio commented 3 years ago

When I turn on the computer(windows 10) Problems will happen

Weird issue! The FormatUnavailable error should be catched by the golang glfw wrapper: https://github.com/go-gl/glfw/commit/e9b2113730bf7ca3f2b783b035541d4a8b3c16cc

And PostEmptyEvent shouldn't panic with this error https://github.com/go-gl/glfw/blob/9b86c984c866400dc34182d3a6aaf4cb5be0a4cf/v3.3/glfw/window.go#L1005 https://www.glfw.org/docs/latest/group__window.html#gab5997a25187e9fd5c6f2ecbbc8dfd7e9

Please open an issue on go-gl/glfw (issue not related with this project). But maybe what's happening is a GLFW_NOT_INITIALIZED error is thrown, then a FormatUnavailable error is thrown concurrently?

Could you more precisely describe what you mean by When I turn on the computer(windows 10) what are the step/configuration to reproduce the error ?

leedstyh commented 3 years ago

same issue here, @itMicmouse have you figure out how to fix this?

zhileichen commented 3 years ago

@pchampio we are coming into the same issue. The crash happens randomly, mostly happens when texting with keyboard.

goroutine 6146 [running]:
runtime/debug.Stack(0x0, 0x1b01ca0, 0xc000088a50)
    c:/go/src/runtime/debug/stack.go:24 +0xa5
runtime/debug.PrintStack()
    c:/go/src/runtime/debug/stack.go:16 +0x29
github.com/go-flutter-desktop/go-flutter/plugin.(*MethodChannel).handleMethodCall.func1(0xc00001c240, 0x13, 0xc00028c420)
    C:/Users/ee/Workspace/go-flutter/plugin/method-channel.go:219 +0x15f
panic(0x1966300, 0xc0000b6160)
    c:/go/src/runtime/panic.go:969 +0x1c7
github.com/go-gl/glfw/v3.3/glfw.acceptError(0x0, 0x0, 0x0, 0xc000253d60, 0x123f5ab)
    C:/Users/ee/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:178 +0x20c
github.com/go-gl/glfw/v3.3/glfw.panicError(...)
    C:/Users/ee/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:185
github.com/go-gl/glfw/v3.3/glfw.PostEmptyEvent()
    C:/Users/ee/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/window.go:1007 +0x3f
github.com/go-flutter-desktop/go-flutter.responseSender.Send(0xc0001cebe0, 0xc000088750, 0xc0000061c8, 0xc000098140, 0x6, 0x40)
    C:/Users/ee/Workspace/go-flutter/messenger.go:129 +0x5a
github.com/go-flutter-desktop/go-flutter/plugin.(*MethodChannel).handleMethodCall(0xc00028c420, 0x1b02300, 0xc000283650, 0xc00001c240, 0x13, 0x0, 0x0, 0x1b02280, 0xc0001f2040)
    C:/Users/ee/Workspace/go-flutter/plugin/method-channel.go:246 +0x518
created by github.com/go-flutter-desktop/go-flutter/plugin.(*MethodChannel).handleChannelMessage
    C:/Users/ee/Workspace/go-flutter/plugin/method-channel.go:207 +0x271
panic: FormatUnavailable: Win32: Failed to convert clipboard to string: 操作成功完成。 

goroutine 18 [running, locked to thread]:
github.com/go-gl/glfw/v3.3/glfw.acceptError(0x0, 0x0, 0x0, 0xc000005f60, 0x1)
    C:/Users/ee/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:178 +0x20c
github.com/go-gl/glfw/v3.3/glfw.panicError(...)
    C:/Users/ee/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/error.go:185
github.com/go-gl/glfw/v3.3/glfw.PostEmptyEvent()
    C:/Users/ee/go/pkg/mod/github.com/go-gl/glfw/v3.3/glfw@v0.0.0-20200707082815-5321531c36a2/window.go:1007 +0x3f
github.com/go-flutter-desktop/go-flutter.(*EventLoop).PostTask(0xc0001c1e90, 0x2f47c130, 0x2dc51b38, 0x15324a2d6b2c)
    C:/Users/ee/Workspace/go-flutter/event-loop.go:73 +0x12e
github.com/go-flutter-desktop/go-flutter/embedder.proxy_post_task_callback(...)
    C:/Users/ee/Workspace/go-flutter/embedder/embedder_proxy.go:94
github.com/go-flutter-desktop/go-flutter/embedder._cgoexpwrap_de84f3eb1d92_proxy_post_task_callback(0x2f47c130, 0x2dc51b38, 0x15324a2d6b2c, 0xc0001e80d8)
    _cgo_gotypes.go:916 +0x52
zhileichen commented 3 years ago

crash at this line: https://github.com/go-gl/glfw/blob/9b86c984c866400dc34182d3a6aaf4cb5be0a4cf/v3.3/glfw/error.go#L178

leedstyh commented 3 years ago

Yeah @zhileichen I comment out this line and the app works fine. I'm pretty sure my app has nothing to do with clipboard, not sure why panic on it.

pchampio commented 3 years ago

Does hover run -b '@fix/post-task-panic' fixes this issue ? (with the latest version of hover, the -b flags need to be used with: go env -w GOPROXY=direct)

pchampio commented 3 years ago

Or hover build linux -b '@fix/post-task-panic'

kechkibet commented 3 years ago

Hi, On running the above command i get the following error: hover: Downloading 'go-flutter' '@fix/post-task-panic' go get github.com/go-flutter-desktop/go-flutter'@fix/post-task-panic': invalid github.com/ import path "github.com/go-flutter-desktop/go-flutter'" hover: Updating go-flutter to '@fix/post-task-panic' version failed: exit status 1

Kindly advise.

pchampio commented 3 years ago

Can you try go env -w GOPROXY=direct and run hover build linux -b '@fix/post-task-panic' afterwards ? Or maybe something like this: https://stackoverflow.com/questions/20458796/unrecognized-import-path-with-go-get

kechkibet commented 3 years ago

Got it to run without the quites i.e. hover build windows-msi -b @fix/post-task-panic

pchampio commented 3 years ago

Does it fixes the issue ? can you provide some logs

kechkibet commented 3 years ago

i have sent msi for testing, is there a way to capture logs on release build?

pchampio commented 3 years ago

no

itMicmouse commented 3 years ago

I think I solved the problem but I don't like it

 p.window.SetFocusCallback(func(w *glfw.Window, focused bool) {
        if focused {
            text, err := clipboard.ReadAll()
            if err != nil {
                if text == "" {
                    clipboard.WriteAll("")
                }
            }
        }
    })
itMicmouse commented 3 years ago

@pchampio The contents of the clipboard cause a crash so when get focuse test it and reset

itMicmouse commented 3 years ago

i have sent msi for testing, is there a way to capture logs on release build?

const (
    kernel32dll = "kernel32.dll"
)
kernel32 := syscall.NewLazyDLL(kernel32dll)
    setStdHandle := kernel32.NewProc("SetStdHandle")
    sh := syscall.STD_ERROR_HANDLE
    v, _, err := setStdHandle.Call(uintptr(sh), uintptr(file.Fd()))
    if v == 0 {
        return err
    }

I use this get golang err log but sometimes it doesn't work

leedstyh commented 2 years ago

Will fix/post-task-panic be merged?

pchampio commented 2 years ago

Can you check if that branch fixes the issue ?

You have to clone the repo, checkout to the correct branch and use the replace directive in your project.

https://github.com/go-flutter-desktop/go-flutter/wiki/Setting-up-hover-to-use-a-home-made-version-of-'go-flutter'#work-on-go-flutter-source-code

leedstyh commented 2 years ago

yes that branch fix the issue @pchampio