-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Move PointerDataPacketConverter
from PlatformView
to RuntimeController
#51952
Move PointerDataPacketConverter
from PlatformView
to RuntimeController
#51952
Conversation
Update: There are some unexpected unit test failures and I'm resolving. |
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. |
…into pointer-data-converter-move
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.
is the RuntimeController to be per view? or is it going to be shared by multipleview?
The runtime controller is 1 per Dart VM, so it is shared by all views within a single engine instance. |
@@ -124,7 124,9 @@ static void TestSimulatedInputEvents( | |||
for (int i = 0, j = 0; i < num_events; j = 1) { | |||
double t = j * frame_time; | |||
while (i < num_events && delivery_time(i) <= t) { | |||
ShellTest::DispatchFakePointerData(shell.get()); | |||
// Use a different x every time for the pointer data converter to | |||
// generate non-empty events. |
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.
Should we move the "use a different x" trick to DispatchFakePointerData
's implementation? I don't feel strongly about this, feel free to keep as is.
runtime/runtime_controller.cc
Outdated
platform_configuration->DispatchPointerDataPacket(packet); | ||
std::unique_ptr<PointerDataPacket> converted_packet = | ||
pointer_data_packet_converter_.Convert(packet); | ||
if (converted_packet->GetLength() != 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.
I see PlatformView::DispatchPointerDataPacket
didn't have this length check before. Could you explain why it was 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.
You're right. It was a legacy design that proves to be no longer necessary. I've removed the length check and all code that was created for it.
If that is the case, should we still to put it below this level? The converter has state to keep track of pointer down or up, and each converter state should not be mixed between different view. If we put in runtime controller, we would have to maintain one converter per view. |
The runtime controller is 1 per engine, and putting the converter under I don't think it needs to keep states by views, but even if we need to, we can add a private class under it. And even in that case, the converter needs to be aware of views, which |
If you have a gesture across multiple view, like a drag and drop, should they be treated as one gesture, or 2 gesture one for each view? sharing the same state or not will change how pointer event is synthesized
Can you explain a bit more? what information from the view does converter need? |
…into pointer-data-converter-move
The converter simply needs to know when a view is added or removed. However, currently we managed to implement the entire multi-view rendering without adding such API to Well, now that I think about it, it might have been a better idea to add This goes with the current convention on how a message is dispatched to the shell by platforms that do not use the embedder API. For example, iOS dispatches a system pointer event to the shell by: engine/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm Lines 342 to 348 in 932c550
The iOS platform does not operate the shell, but operate the platform view. @loic-sharma What do you think? |
The idea is that, a pointer's state is indexed by its pointer ID. The converter tracks whether this pointer travels across the view boundary and synthesize add/remove events accordingly. An easier way to think about it is what Flutter "remembers" about pointers of an app.
|
I think the Also, the |
yes that can work, but then the converter will be more complex to not only memorize the pointer is down/up, it also need to know which view the pointer has been downed on. I am not too familiar with the shell/platformview/view relationship, if it makes more sense to handle it in the shell level, then I think this is fine. |
But this is unavoidable. The native platforms typically dispatch pointer-add/remove-events when a pointer enters/leaves a view. The app would like to know it as well. So this behavior is intended. The only problem is how to organize our data to compute the logic conveniently. If we don't dispatch pointer-add/remove-events when a pointer enters/leaves a view, what's the behavior then? When the pointer hovers out of the Flutter window, Flutter probably won't receive any pointer events, and therefore the app will stop seeing pointer events for a long time before it sees another pointer event faraway when the pointer enters a Flutter view again. |
Are we making progress on this? |
We definitely need a pointer add when pointer enters, not sure about leaves. I think most native app don't send pointer up when pointer leaves a window. If you want to mimic the behavior with a single pointerpacketconverter, it need to constantly checking whether a move/hover has entered/leaves a new view. If we keep separate converter for each view, it should mostly work out of the box. However, as I state before, if this is the place that makes most sense for pointerpacketconverter, then i guess we have no choice. |
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.
Talked with @dkwingsmt offline. It makes sense to pull these kind of logic out of platform view. LGTM
…147444) flutter/engine@8af10eb...cecf5aa 2024-04-26 [email protected] Move `PointerDataPacketConverter` from `PlatformView` to `RuntimeController` (flutter/engine#51952) 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 is a refactor that moves the
PointerDataPacketConverter
fromPlatformView
toRuntimeController
.This change is made for the following reasons:
PlatformView
, making it closer to a pure virtual class.The reason to choose
RuntimeController
as the destination is becauseRuntimeController
manages a map for views, which is required for the converter to implement a later patch #51925.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.