-
Notifications
You must be signed in to change notification settings - Fork 6k
Add shell api to set default for windows data #14002
Conversation
75a4b80 to
1f3b56f
Compare
|
|
||
| namespace flutter { | ||
|
|
||
| RuntimeController::RuntimeController( |
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.
RuntimeController constructor will always need window data.
2190ab4 to
4aad044
Compare
|
cc @xster |
|
Can you elaborate on the use case? The default frame size is zero and a frame wont get rendered by the rasterizer at that size. So the first frame that ends up on screen will already be the result of the setter to the viewport metrics. |
The windows data here is the default value, those are to be set before user setting and viewport metric is flushed to windows.dart. In the most case, we don't care about the default value because those setting will be flushed during viewcontroller/activity creating. In the add to app scenario, the view controller or activity may not exist when the framework app is running, and the app is running with the default window data. For now, this pr only set applifecycle default value to be detached for android and ios. This pr will open a lot of opportunities to set those default so that the app can warm up in a more reasonable way in the case of missing viewcontroller or activity. |
|
This is also a refactoring. The existing test should cover it. Except in the case of non ios and android platform it uses the 'default' window data in runtime_controller.h. I do not know how to test it. I would imagine the test would be using shell:create to create the shell and verify window.dart has the correct value. I don't know if this test is possible. @chinmaygarde do you have any suggestion? |
|
This requires some more love |
|
@chinmaygarde this is ready for re-review. |
|
Also add @gaaclarke |
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 would like to see the change that fixes the issue in the PR as well.
shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
Outdated
Show resolved
Hide resolved
shell/platform/darwin/ios/framework/Source/FlutterDartProject.mm
Outdated
Show resolved
Hide resolved
5fd6af4 to
17c073d
Compare
Previously, it will set the lifecylce enum to be detached by default for all platforms, and expects the platform to update the lifecycle enum when they are ready. I also addressed all comments, this is ready for review |
gaaclarke
left a comment
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.
LGTM with a few nits. Sorry about the delay in the review, I was OOO.
runtime/runtime_controller.cc
Outdated
| std::string p_advisory_script_entrypoint, | ||
| const std::function<void(int64_t)>& idle_notification_callback, | ||
| WindowData p_window_data, | ||
| const WindowData p_window_data, |
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.
Ideally this should be a const ref:
const WindowData& p_window_data
runtime/runtime_controller.h
Outdated
| std::string advisory_script_uri, | ||
| std::string advisory_script_entrypoint, | ||
| const std::function<void(int64_t)>& idle_notification_callback, | ||
| const WindowData data, |
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.
Const ref here too.
runtime/window_data.h
Outdated
| /// The struct of platform-specific data used for initializing ui.Window. | ||
| /// | ||
| /// framework may request data from ui.Window before platform is properly | ||
| /// configured. Uses this struct to set the desired default value for ui.Window |
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.
Who "uses this struct"? I'd mention Engine and add a link to it.
runtime/window_data.h
Outdated
| /// | ||
| /// * flutter::Shell::Create, which takes a window_data to initialize the | ||
| /// ui.Window | ||
| /// attached to it. |
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.
nit: needs re-formatting.
shell/common/shell.h
Outdated
| /// Unlike the simpler variant of this factory method, this method | ||
| /// allows for specification of window data. If this is the first | ||
| /// instance of a shell in the process, this | ||
| /// call also bootstraps the Dart VM. |
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.
nit: line wrapping.
| FML_CHECK(pthread_key_delete(thread_destruct_key_) == 0); | ||
| } | ||
|
|
||
| WindowData AndroidShellHolder::getDefaultWindowData() { |
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.
Given that this doesn't rely on object state at all, this could be a static function local to the TU.
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.
(Either way this function should start with a capital though)
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.
On third thought, if you don't expect this to change significantly in the future or be called from a ton of places, I'd probably just inline the variable declaration and field initialisation at the usage site above (and similar for the obj-c version).
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 separated this out to a method for readability. We might want to fill in more default value for add 2 app, for example, viewport metrics.
cbracken
left a comment
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.
lgtm modulo nits
This reverts commit cef181f.
This pr enables embedding to set default values for window data.
It does following things
4, Makes Android and IOS pass in windowData with their own defaults
relevant issue: flutter/flutter#45270