Skip to content

Clean up #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
May 25, 2020
Merged

Clean up #435

merged 14 commits into from
May 25, 2020

Conversation

pchampio
Copy link
Member

No description provided.

@provokateurin
Copy link
Member

}

// GoError convert a FlutterEngineResult to a golang readable error
func (res Result) GoError(caller string) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking the caller name as argument to GoError(), we could use runtime information to obtain the caller name.
Example usage:

    pc, _, _, ok := runtime.Caller(1)
    callerDetails := runtime.FuncForPC(pc)
    if ok && callerDetails != nil {
        fmt.Printf("called from %s\n", callerDetails.Name())
    }

I'm not sure what scenario's we could encounter where ok is false. It will be false when too many frames are skipped, but for value 1 that can never be the case in Go.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, I think this won't work when debug symbols are stripped, which hover tells Go to do when building a release build. (-ldflags="-s -w")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this new (Result).GoError() by the way, a lot better to pass errors arround instead of Result. 👍 😎

@pchampio pchampio marked this pull request as ready for review May 11, 2020 17:47
@pchampio
Copy link
Member Author

@pchampio
Copy link
Member Author

pchampio commented May 13, 2020

TODO: add go-flutter/plugin tag and clean the plugin repo / update plugin docs.

@GeertJohan
Copy link
Member

Can we keep versions for the plugin submodule and the root module the same? Afaik if you version tag without submodule prefix (such as plugin/v1.2.3), it automatically uses the root tag (v1.2.3).

@pchampio
Copy link
Member Author

pchampio commented May 13, 2020

Yes, I intent to tag with: plugin/v1.2.3!
Similarly to what we are doing in the plugin repo: https://github.com/go-flutter-desktop/plugins/blob/master/image_picker/go.mod#L1 https://github.com/go-flutter-desktop/plugins/releases

And it should not use the 'root' (do you mean the go-flutter?) tag, when developing I had error like:

go: github.com/go-flutter-desktop/[email protected] requires
	github.com/go-flutter-desktop/go-flutter/[email protected]: invalid version: unknown revision 000000000000

It couldn't find any revision.

@GeertJohan
Copy link
Member

I think that may be because there is no tag on the repository yet where the plugin folder contains a go.mod?

If it works to publish by using only the 'root' tag, I think that would be preferable. Easier to maintain and less prone to errors. Always the same version for both go-flutter and plugins.

@pchampio
Copy link
Member Author

pchampio commented May 18, 2020

Oh!!
Ok, didn't understand your last comment. Sorry.

I'm not sure about connecting both modules into the same tag.
IMHO:

  • ATM the plugin repo can be tagged as >v1 while I like to keep go-flutter <1.
  • it's been more than 6month since the last update on the plugin module, If we connect both modules tags, it would mean that we would have updates on plugin that are empty (and a lot of them..).

@pchampio pchampio requested a review from GeertJohan May 22, 2020 20:46
@pchampio
Copy link
Member Author

pchampio commented May 22, 2020

Ready for review!
I've commented the code that required compiling go-flutter against the master channel of flutter (AOT feature).
Once this PR is merged, I'll open a new PR un-commenting the AOT related sutff.

@GeertJohan with my above comment, especially the 2nd point?

@pchampio pchampio changed the title Clean up and aot Clean up May 22, 2020
@GeertJohan
Copy link
Member

Thanks for the elaboration @pchampio, I now agree with you that the plugins package could have it's own version tags. Indeed it can be tagged 1.0

Will this always play well and not cause dependency cycles and version issues?

  • go-flutter requires go-flutter/plugin v1.x
  • path_provider requires go-flutter/plugin v1.x
  • path_provider requires go-flutter to perform a compile time type check var _ flutter.Plugin = &PathProviderPlugin{}. This is optional, but nice for plugin developers to do as it increases compile-time safety.

The third item does introduce the go-flutter package as dependency, we could avoid that by moving the Plugin interface into the plugin package, and replacing the Plugin interface in the flutter package with a retype of the plugin.Plugin interface (package flutter; import "github.com/go-flutter-desktop/go-flutter/plugin"; type Plugin plugin.Plugin).

One other thing we should consider at this point:
Should the plugin package be moved to its own repo? I don't have a clear opinion on this yet, but I was just thinking that IF we ever want to move the plugin package to its own repo, then right now would be the perfect time (pre 1.0, with go-flutter being marked unstable (0.x) the breaking change would still be ok).
It does break existing imports of the package, but maybe creating the module will break that anyway?
What are the downsides of having a module in a module?

@@ -66,8 +66,6 @@ const (
//
type StandardMessageCodec struct{}

var _ MessageCodec = StandardMessageCodec{} // compile-time type check
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a useful assertion?

Comment on lines +37 to +39
channel.HandleFuncSync("Clipboard.setData", p.handleClipboardSetData)
channel.HandleFuncSync("Clipboard.getData", p.handleClipboardGetData)
channel.HandleFuncSync("SystemNavigator.pop", p.handleSystemNavigatorPop)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses of HandleFuncSync instead of a glfwTasker

@pchampio
Copy link
Member Author

Will this always play well and not cause dependency cycles and version issues?

True, a change on go-flutter/plugin might require the use of an newer go-flutter/.
Ok, I now get your point.

After more though, I now think we should NOT add a module in go-flutter/plugins.
It's best if both are connected for the dependency (go-flutter/plugin -> go-flutter) requirement, and the best way to perform this is to having the go-flutter/plugin in the same tag as go-flutter, so, the same go.mod.

@@ -125,8 +126,7 @@ func (r responseSender) Send(binaryReply []byte) {
// TODO: detect multiple responses on the same message and spam the log
// about it.

// It would be preferable to replace this with channels so sending
// doesn't have to wait on the main loop to come around.
glfw.PostEmptyEvent()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:

flutter: 00:00 +0: Test Battery Plugin result
Send took 25.112162ms
flutter:           -- Battery level at 55 % .
flutter: 00:00 +1: Complex plugin Test StandardMethodCodec array of map
Send took 25.079956ms
flutter: 00:00 +2: Complex plugin Test golang InvokeMethodWithReply
Send took 25.104811ms
flutter: 00:03 +3: Complex plugin Custom errors
go-flutter: handler for method 'getError' on channel 'instance.id/go/data' returned an error: Some error
Send took 25.076353ms
flutter: 00:03 +4: Complex plugin Test golang CatchAllHandleFunc
Send took 25.06359ms
flutter: 00:03 +5: (tearDownAll)
flutter: 00:03 +6: All tests passed!
Send took 25.213678ms
go-flutter: closing application
flutter: 00:03 +6: All tests passed!

After:

flutter: 00:00 +0: Test Battery Plugin result
Send took 53.526µs
flutter:           -- Battery level at 55 % .
flutter: 00:00 +1: Complex plugin Test StandardMethodCodec array of map
Send took 77.784µs
flutter: 00:00 +2: Complex plugin Test golang InvokeMethodWithReply
Send took 72.655µs
flutter: 00:03 +3: Complex plugin Custom errors
go-flutter: handler for method 'getError' on channel 'instance.id/go/data' returned an error: Some error
Send took 53.314µs
flutter: 00:03 +4: Complex plugin Test golang CatchAllHandleFunc
Send took 209.681µs
flutter: 00:03 +5: (tearDownAll)
Send took 82.624µs
go-flutter: closing application
flutter: 00:03 +6: All tests passed!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that's a serious speed improvement! Nice 🚀

@pchampio pchampio requested a review from GeertJohan May 25, 2020 11:32
p.glfwTasker.Do(func() {
p.window.SetClipboardString(newClipboard.Text)
})
p.window.SetClipboardString(newClipboard.Text)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, just make sure I get this right; this code is guaranteed to run in the glfw main thread, which is why we don't need to add this as task on the glfwTasker?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, HandleFuncSync runs on the main thread.

@pchampio pchampio merged commit 85b3586 into master May 25, 2020
@pchampio pchampio deleted the clean_up_and_aot branch May 25, 2020 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants