-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Enable support for dynamic view resizing #169605
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
base: master
Are you sure you want to change the base?
Conversation
Just as a heads-up; this will NOT be submitted until @mboetger and/or @LouiseHsu have verified that this works for them in iOS/Android embedders. |
@@ -32,6 +32,8 @@ class RuntimeDelegate { | |||
std::unique_ptr<flutter::LayerTree> layer_tree, | |||
float device_pixel_ratio) = 0; | |||
|
|||
virtual void ResizeView(int64_t view_id, double width, double height) = 0; |
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.
Consider returning bool
instead to indicate whether the platform could actually resize the view. The default could just return false
. Then the runtime controller can log when the result is false
saying something like "Could not resize platform view.". You can do thread checks on platforms that don't support off main thread resizes and the threads haven't been merged.
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.
Oh I like it! Will do.
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 like keeping the thread checks in the respective platform implementations.
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.
If we merge the resize view callback with the present view callback, FlutterCompositor.present_view_callback
, the engine should assume the resize operation failed if the present view callback returns false
.
@@ -432,6 +432,10 @@ void RuntimeController::Render(int64_t view_id, | |||
if (view_metrics == nullptr) { | |||
return; | |||
} | |||
if (width != view_metrics->physical_width || |
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.
Don't we have a NearEqual
since we are doing floating point comparisons?
@@ -1725,6 +1725,11 @@ typedef void (*FlutterViewFocusChangeRequestCallback)( | |||
const FlutterViewFocusChangeRequest* /* request */, | |||
void* /* user data */); | |||
|
|||
typedef void (*FlutterResizeViewCallback)(int64_t /* view ID */, | |||
double /* physical_width */, |
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: FlutterSize
instead?
void Shell::OnEngineResizeView(int64_t view_id, double width, double height) { | ||
FML_DCHECK(is_set_up_); | ||
|
||
if (!task_runners_.GetPlatformTaskRunner()->RunsTasksOnCurrentThread()) { |
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 prefer removing this. The engine shouldn't care if the platform supports off main thread merges. Fuchsia for instance does support it. An embedder could too. Each embedder should have this check though (when they don't support it).
Barring the engine having an opinion about the platforms support for off-main-thread platform view resizes (it should not), everything else lgtm. |
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not *implement* support in any embedder. This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved. When Flutter applications call `FlutterView.render` with a non-null `size` parameter, the size will be compared to the existing view size (if any), and if different, a call to `PlatformView::ResizeView` will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size. Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly. Related patches: * `dart:ui`: flutter/engine#48090 * framework: flutter#138648 * framework reland: flutter#140918 * Web: flutter/engine#50271 Issue: flutter#169147 Issue: flutter#149033
40f6719
to
a444434
Compare
Whats the progress on this? |
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.
Waiting on updates from feedback based on offline conversation with Loic...
Sounds good. Consider making this a draft so triagers leave this alone maybe. |
This enables support for dynamic view resizing in non-web embedders. While this patch enables support and exposes API for dynamic view resizing in non-web embedders and in the embedder API, it does not implement support in any embedder.
This feature is restricted to embedders with merged UI and platform thread due to the need to inform the embedder of the updated view size synchronously with presenting the content. With some effort, we could implement synchronisation logic that supports non-thread-merged embedders. See ResizeSynchronizer in the macOS embedder for details of what's involved.
When Flutter applications call
FlutterView.render
with a non-nullsize
parameter, the size will be compared to the existing view size (if any), and if different, a call toPlatformView::ResizeView
will be triggered. Embedders can respond to this call by resizing the underlying platform-specific FlutterView to the appropriate size.Extracts a resize_view_callback to the embedder API that custom embedders can register to receive the updated size from the engine, and adapt their views accordingly.
Related patches:
dart:ui
: Dynamic view sizing [dart:ui] engine#48090Issue: #169147
Issue: #149033
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.