-
Notifications
You must be signed in to change notification settings - Fork 6k
Move Shell::Add/RemoveView
to PlatformView
and refine embedder API doc
#52003
Move Shell::Add/RemoveView
to PlatformView
and refine embedder API doc
#52003
Conversation
@chinmaygarde Can you take a look? I'm not sure whether this is a necessary change. I'm proposing this only because I supposed the |
//---------------------------------------------------------------------------- | ||
/// @brief Used to forward events from the platform view to interested | ||
/// subsystems. This forwarding is done by the shell which sets | ||
/// itself up as the delegate of the platform view. | ||
/// | ||
class Delegate { | ||
public: | ||
using AddViewCallback = PlatformView::AddViewCallback; |
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: Is this necessary? You can just use the typedef from the parent.
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.
The compiler requires PlatformView::AddViewCallback
(for both the methods in Delegate
and Shell
) instead of simply AddViewCallback
without it, which is definitely not necessary though, and I'm down to remove it. What do you think?
@@ -51,13 +51,17 @@ namespace flutter { | |||
/// | |||
class PlatformView { | |||
public: | |||
using AddViewCallback = std::function<void(bool added)>; |
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.
What do the added
and removed
arguments to the callback mean? If added
is false, why invoke the AddViewCallback
? Perhaps document that?
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.
Both the add and the remove callbacks rely on the result. For example, in the Windows embedder as implemented in #51923
- After calling
AddView
, the embedder blocks until a result is reported, which decides whether the returnedFlutterWindowsView
is null. (This eager blocking can be optimized in the future, but this is an easier approach for now.) - The embedder also pre-allocate resources after calling
AddView
before the callback, and if the result turns out a failure, then the resources are deallocated. The pre-allocation ensures that the framework can start operating the view as soon as they're aware of it. - After calling
RemoveView
, embedder does not deallocate resources until the callback (successful or not). This allows handling any pending operations during this time.
I kept the statement "The embedder should prepare resources in advance but be ready to clean up on failure." since I think this is a very useful implementation suggestion. |
Shell::Add/RemoveView
to PlatformView
Shell::Add/RemoveView
to PlatformView
and refine embedder API doc
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, thanks for cleaning this up!
…146663) flutter/engine@16b0cfd...2d85d12 2024-04-11 [email protected] Roll Skia from 08940c2e0c44 to 5101cbe5a6bb (1 revision) (flutter/engine#52066) 2024-04-11 [email protected] Move `Shell::Add/RemoveView` to `PlatformView` and refine embedder API doc (flutter/engine#52003) 2024-04-11 [email protected] [Fuchsia] Support per app present latency tracing (flutter/engine#51503) 2024-04-11 [email protected] Save and restore OpenGL bindings that are changed by fl_renderer_render (flutter/engine#51887) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…lutter#146663) flutter/engine@16b0cfd...2d85d12 2024-04-11 [email protected] Roll Skia from 08940c2e0c44 to 5101cbe5a6bb (1 revision) (flutter/engine#52066) 2024-04-11 [email protected] Move `Shell::Add/RemoveView` to `PlatformView` and refine embedder API doc (flutter/engine#52003) 2024-04-11 [email protected] [Fuchsia] Support per app present latency tracing (flutter/engine#51503) 2024-04-11 [email protected] Save and restore OpenGL bindings that are changed by fl_renderer_render (flutter/engine#51887) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This PR moves the methods to add or remove views from
Shell
toPlatformView
. By design, theShell
is supposed to be a messenger that glues classes together, whilePlatformView
is the operator that embedders that do not use the embedder API should operate on. The current design was made due to lack of knowledge to this design.This also makes
PlatformView
aware of views, which might be a prerequisite to #51925.This PR also adds some details to embedder API
AddView
andRemoveView
.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.