-
Notifications
You must be signed in to change notification settings - Fork 282
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
Clean up #435
Conversation
@pchampio flutter/engine#18146 got merged flutter/engine@d96f962 |
} | ||
|
||
// GoError convert a FlutterEngineResult to a golang readable error | ||
func (res Result) GoError(caller string) error { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
)
There was a problem hiding this comment.
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. 👍 😎
Tested on linux using: https://github.com/flutter-rs/engine-builds/releases/tag/f-d96f962ca21a104b08836f34814eb6b267937511 using profile mode. |
TODO: add go-flutter/plugin tag and clean the plugin repo / update plugin docs. |
Can we keep versions for the plugin submodule and the root module the same? Afaik if you version tag without submodule prefix (such as |
Yes, I intent to tag with: And it should not use the 'root' (do you mean the go-flutter?) tag, when developing I had error like:
It couldn't find any revision. |
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. |
Oh!! I'm not sure about connecting both modules into the same tag.
|
Ready for review! @GeertJohan with my above comment, especially the 2nd point? |
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?
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 ( One other thing we should consider at this point: |
plugin/standard-message-codec.go
Outdated
@@ -66,8 +66,6 @@ const ( | |||
// | |||
type StandardMessageCodec struct{} | |||
|
|||
var _ MessageCodec = StandardMessageCodec{} // compile-time type check |
There was a problem hiding this comment.
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?
…lutter into clean_up_and_aot
channel.HandleFuncSync("Clipboard.setData", p.handleClipboardSetData) | ||
channel.HandleFuncSync("Clipboard.getData", p.handleClipboardGetData) | ||
channel.HandleFuncSync("SystemNavigator.pop", p.handleSystemNavigatorPop) |
There was a problem hiding this comment.
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
True, a change on go-flutter/plugin might require the use of an newer go-flutter/. After more though, I now think we should NOT add a module in go-flutter/plugins. |
@@ -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() |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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 🚀
p.glfwTasker.Do(func() { | ||
p.window.SetClipboardString(newClipboard.Text) | ||
}) | ||
p.window.SetClipboardString(newClipboard.Text) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
No description provided.