Skip to content

prototype ignore semantics actions - #37199

Closed
chunhtai wants to merge 3 commits into
flutter:masterfrom
chunhtai:issues/37162
Closed

chunhtai wants to merge 3 commits into
flutter:masterfrom
chunhtai:issues/37162

Conversation

@chunhtai

@chunhtai chunhtai commented Jul 29, 2019 •

Copy link
Copy Markdown
Contributor

Description

This is a prototype.

expects behavior as following

if ignoringSemantics = true
     no semantics segmantics should be collected from the subtree
else
     if ignoring= true
           collect all the semantics except tap and longpress
    else
           collect all semantics

Related Issues

#37162

Tests

I added the following tests:

Replace this with a list of the tests that you added as part of this PR. A change in behaviour with no test covering it
will likely get reverted accidentally sooner or later. PRs must include tests for all changed/updated/fixed behaviors. See [Test Coverage].

Design doc https://docs.google.com/document/d/1WuVBc58_wV6__ZCe1NgYsnvTJtSdOtVcwSzPwM_YT74/edit?usp=sharing

@fluttergithubbot fluttergithubbot added a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) p: cupertino_ui cupertino_ui package in flutter/packages p: material_ui material_ui package in flutter/packages labels Jul 29, 2019
@fluttergithubbot

Copy link
Copy Markdown
Contributor

It looks like this pull request may not have tests. Please make sure to add tests before merging. While there are exceptions to this rule, if this patch modifies code it is probably not an exception.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

/cc @dnfield

@fluttergithubbot fluttergithubbot added the framework flutter/packages/flutter repository. See also f: labels. label Jul 29, 2019

@goderbauer goderbauer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may be worthwhile to write a little design document for this to reflect on what the goals for this API are and to answer some of the open questions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why only block tap and longPress? I think a RenderIgnorePointer also blocks scrolling and other gestures, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We will probably want to block more, This is more like a place holder for now

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we have a use case were we only need to block selective actions? Or is it all-or-nothing?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If we go the down the selective route - how do we deal with newly added semantics actions that people didn't know about when writing their render objects that use this functionality?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I believe we might want to do selective route for example we are not likely to block
SemanticsAction.showOnScreen in ignoring pointer widget.

For newly added semantics actions, I really can't think of a comprehensive way to improve this. we can try to group the actions into different subgroup, for example, we can have a subgroup called PointerActions that will include all the pointer related semantics action, and the the renderobject can directly mute the subgroup instead individual actions. The person who add the new semantics action need to also include the action into the correct subgroup.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

showOnScreen is kind of a special SemanticsAction since it is not directly user-triggered. It would probably be good to have a way to block all user-initiated actions.

Having said that, showOnScreen as a semantics action is really only relevant if the node is scrollable. And scrolling is one of the actions we are blocking, with ignorepointer, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if RenderIgnorePointer could set "blockedActions" on the SemanticsConfiguration it returns from describeSemanticsConfiguration instead of adding this API here. The semantics compiler would than have to resolve this as it rebuilds the tree based on that changed configuration...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is this possible? We can do this if we calculate the subtree's blockedActions without any caching. If we want to use cache, we need a way to invalidate subtree's caches. I can't think of good way to do that if we didn't do it in renderobject level.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It may make more sense to cache these things on the SemanticsNode itself. We already do this for other things, like the elevation imposed by a parent on its children or the parent paint clip:
https://master-api.flutter.dev/flutter/semantics/SemanticsNode/elevationAdjustment.html
https://master-api.flutter.dev/flutter/semantics/SemanticsNode/parentPaintClipRect.html

It would probably be more idiomatic to have specify the blocked actions on the SemanticsConfiguration and cache things on the SemanticsNode.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

those case are setting semantics configuration for compilechildren to finalize the value. However, the blocked action I did here is blocking during semantics configuration setup. The biggest difference is that make node dirty will re compile its children SemanticsFragment but it does keep the old cache of semantics configuration. in the case of elevationAdjustment or parentPainterClipRect, it is ok because the subtree semantics configuration did not change. it just need to recompile. However, in my case it will break because the subtree need to reconfig semantics configuration. I think if we don't want to recursively mark subtree dirty, we can try to strip out blocked semanticsactions during compilechildren. I am not sure if there is any side effect tho.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just the parent? Or all ancestors?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All ancestors, sorry for the confusing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How is the cache invalidated if the parent's _inheritedMutedSemanticsActions change?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the recursive markRenderObjectNeedsSemanticsUpdate should invalidate all the subtree cache.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That is a departure from how SemanticsUpdate marking works right now. Right now, if node A is marked as needing an update, all its children will also be updated without requiring to be marked as needing an update.

The subtree could potentially be very large (think about a modal dialog that blocks interactions with everything in the route below it), so performance-wise it may not be a good idea to walk everything.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How is it guaranteed that the parent's _inheritedMutedSemanticsActions are up-to-date at this point?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

if any ancestor has change, its subtree should have all their _cachedMutedSemanticsActions set to null

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe you do not need to walk down to the leaves. If you mark a node as needing semantics update, the entire subtree gets re-build anyways starting with the marked node.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

its subtree already cached both _cachedMutedSemanticsActions and _cachedSemanticsConfiguration which will need to be removed by calling markNeedsSemanticsUpdate. I feel a bit scared to manually remove the cache without going through markNeedsSemanticsUpdate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you could do .containsAll. Same thing either way though.

@chunhtai
chunhtai force-pushed the issues/37162 branch 2 times, most recently from 75ee4f7 to 4903c0e Compare August 5, 2019 18:12
@chunhtai

chunhtai commented Aug 5, 2019

Copy link
Copy Markdown
Contributor Author

Refactored @goderbauer

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

readOnly in EditableText will make it not an ediablebox

@chunhtai

Copy link
Copy Markdown
Contributor Author

@goderbauer finalize the prototype, and updated design doc. Test will be added after we decide this is the route we want to pursue.

@chunhtai

chunhtai commented Mar 3, 2020

Copy link
Copy Markdown
Contributor Author

closed for now until i have time to get back to it

@chunhtai chunhtai closed this Mar 3, 2020
@chunhtai chunhtai mentioned this pull request Jul 24, 2020
13 tasks
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants