Skip to content

Breaking change: MouseTrackerAnnotation requires parameter "key"#3468

Closed
dkwingsmt wants to merge 3 commits intomasterfrom
mousetrackerannotation-requires-parameter-key
Closed

Breaking change: MouseTrackerAnnotation requires parameter "key"#3468
dkwingsmt wants to merge 3 commits intomasterfrom
mousetrackerannotation-requires-parameter-key

Conversation

@dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Dec 20, 2019

Breaking change documentation for PR flutter/flutter#46034.
Design doc: https://flutter.dev/go/key-based-mouse-tracker-annotation

@googlebot googlebot added the cla: yes Contributor has signed the Contributor License Agreement label Dec 20, 2019
void detach() {
- RendererBinding.instance.mouseTracker.detachAnnotation(_hoverAnnotation);
+ RendererBinding.instance.mouseTracker.detachAnnotation(_hoverAnnotation.key);
super.detach();
Copy link
Contributor

Choose a reason for hiding this comment

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

why does the render object do this instead of the layer tree? seems weird that you have to independently tell the layer tree and the mouse tracker about the annotations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are multiple reasons:

  • Annotation attachment is used to indicate widget presence. Generally, an annotation should be detached if the owner widget is unmounted, for the reason described in Improve MouseTracker lifecycle: Move checks to post-frame flutter#44631 "The change to onExit". Therefore I think it's better to handle it in the render object (or should it be the element?).
  • Historical reason. Attaching and detaching annotations used to have immediate effects (triggering callbacks) and we had to do it during Element.activate and deactivate. This was no longer needed, so now we only need to do it in attach and detach, but we haven't fully moved it to layers yet.
  • Future plan. We're planning to experiment a change that split annotations from the layer tree to fix issues such as Poor performance when subscribing to MouseRegion events flutter#41194. Therefore we'd like to keep it separated from the layer tree (at least for now).

Copy link
Contributor

Choose a reason for hiding this comment

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

It'll still have to be in the layer tree though right? Just done differently than today (many nodes dealing with one layer rather than one layer per node).

This just seems like an unnecessarily awkward API right now.

Anyway, the point of my questions is that you should explain this in the breaking change document. Especially if we're planning on changing this again, we should warn people that we're not done changing this API.

Copy link
Contributor Author

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

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

Fixed review comments, with one comment replied.

@dkwingsmt dkwingsmt changed the title [WIP] Breaking change: MouseTrackerAnnotation requires parameter "key" Breaking change: MouseTrackerAnnotation requires parameter "key" Dec 24, 2019
Copy link
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

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

This LGTM, but @Hixie has the final say.

@dkwingsmt
Copy link
Contributor Author

Closing this because I found out that it's probably neither necessary nor sufficient. I've also closed the corresponding Flutter PR in favor of flutter/flutter#48453.

@dkwingsmt dkwingsmt closed this Jan 9, 2020
@dkwingsmt dkwingsmt deleted the mousetrackerannotation-requires-parameter-key branch January 9, 2020 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Contributor has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants