Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Nov 25, 2019

This pr enables embedding to set default values for window data.

It does following things

  1. Make WindowData a public class in runtime controller
  2. Add windowData a construction parameter for RuntimeController, Engine, and Shell.
  3. If there is no windowData passed in to Shell:Create, it will use the default version of WindowData.
    4, Makes Android and IOS pass in windowData with their own defaults

relevant issue: flutter/flutter#45270

@chunhtai chunhtai added the Work in progress (WIP) Not ready (yet) for review! label Nov 25, 2019
@auto-assign auto-assign bot requested a review from flar November 25, 2019 17:04
@chunhtai chunhtai force-pushed the issues/45270 branch 2 times, most recently from 75a4b80 to 1f3b56f Compare November 25, 2019 18:03

namespace flutter {

RuntimeController::RuntimeController(
Copy link
Contributor Author

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.

@chunhtai
Copy link
Contributor Author

cc @xster

@chinmaygarde
Copy link
Member

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.

@chunhtai
Copy link
Contributor Author

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.

@chunhtai
Copy link
Contributor Author

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?

@chunhtai chunhtai removed the Work in progress (WIP) Not ready (yet) for review! label Dec 2, 2019
@chunhtai
Copy link
Contributor Author

chunhtai commented Dec 2, 2019

This requires some more love

@cbracken
Copy link
Member

@chinmaygarde this is ready for re-review.

@xster xster requested a review from gaaclarke December 19, 2019 00:18
@xster
Copy link
Member

xster commented Dec 19, 2019

Also add @gaaclarke

Copy link
Member

@gaaclarke gaaclarke left a 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.

@chunhtai chunhtai force-pushed the issues/45270 branch 2 times, most recently from 5fd6af4 to 17c073d Compare December 21, 2019 00:18
@chunhtai
Copy link
Contributor Author

chunhtai commented Dec 21, 2019

I would like to see the change that fixes the issue in the PR as well.

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.
This pr fixes this issue by setting the default to detached for ios and android where both platform will update the enum, and set the default to null for all the other platforms who currently do not opt in to handle lifecycle. I provide the api for each platform to set the default once they opt in to handle lifecycle enum.

I also addressed all comments, this is ready for review

Copy link
Member

@gaaclarke gaaclarke left a 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.

std::string p_advisory_script_entrypoint,
const std::function<void(int64_t)>& idle_notification_callback,
WindowData p_window_data,
const WindowData p_window_data,
Copy link
Member

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

std::string advisory_script_uri,
std::string advisory_script_entrypoint,
const std::function<void(int64_t)>& idle_notification_callback,
const WindowData data,
Copy link
Member

Choose a reason for hiding this comment

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

Const ref here too.

/// 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
Copy link
Member

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.

///
/// * flutter::Shell::Create, which takes a window_data to initialize the
/// ui.Window
/// attached to it.
Copy link
Member

Choose a reason for hiding this comment

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

nit: needs re-formatting.

/// 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.
Copy link
Member

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() {
Copy link
Member

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.

Copy link
Member

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)

Copy link
Member

@cbracken cbracken Jan 9, 2020

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).

Copy link
Contributor Author

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.

Copy link
Member

@cbracken cbracken left a comment

Choose a reason for hiding this comment

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

lgtm modulo nits

@chunhtai chunhtai merged commit 7a27e75 into flutter:master Jan 9, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 10, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 11, 2020
NoamDev pushed a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
NoamDev added a commit to NoamDev/engine that referenced this pull request Feb 27, 2020
filmil pushed a commit to filmil/engine that referenced this pull request Mar 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants