Skip to content
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

Slider relies on brittle paint order to work properly #98770

Open
Tracked by #125329
goderbauer opened this issue Feb 18, 2022 · 3 comments
Open
Tracked by #125329

Slider relies on brittle paint order to work properly #98770

goderbauer opened this issue Feb 18, 2022 · 3 comments
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@goderbauer
Copy link
Member

goderbauer commented Feb 18, 2022

The material Slider widget relies on the order in which nodes get precessed during PAINT in order to present itself visually correctly. That's brittle.

Here's the problem: In its paint method _RenderSlider configures the paintValueIndicator painter...

_state.paintValueIndicator = (PaintingContext context, Offset offset) {

... which is used in the paint method of _RenderValueIndicator:

_state.paintValueIndicator?.call(context, offset);

This only works if _RenderSlider is processed before _RenderValueIndicator during PAINT. Otherwise, _RenderValueIndicator.paint will not see the painter configured by _RenderSlider.paint and instead paint with an outdated painter.

Since nodes are processed from deepest to shallowest, this works fine when _RenderSlider is deeper in the tree than _RenderValueIndicator and breaks otherwise. It will also break when the order in which we process nodes during PAINT is flipped around as we did in #98219, which may give us some performance benefits. That PR saw breakages in google3 because of the problem described here (see b/219153804).

Long story short: Slider should not relay on the somewhat brittle order in which nodes get processed during PAINT.

Side node: We should also add a test for this to the framework since this was only caught during a google3 roll. Done: #98772

@goderbauer goderbauer added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Feb 18, 2022
@goderbauer
Copy link
Member Author

That behavior was introduced in #53916. @HansMuller @JoseAlba @clocksmith

@TahaTesser
Copy link
Member

TahaTesser commented Oct 13, 2022

@goderbauer
I wanna pick your brain regarding Slider. I noticed Slider uses FocusableActionDetector on entire _SliderRenderObjectWidget, which paints track, thumb and value indicator altogether.

I wanna be able to detect hover/focus just on thumbs to update overlays and as well as to add support thumb overlays in RangeSlider, as it has 2 thumbs, detecting which thumb is hovered and focused is very important.

I was thinking instead, I could use CustomMultiChildLayout or MultiChildRenderObjectWidget to render all these components individually.

Something like this:

        child: CompositedTransformTarget(
          link: _layerLink,
          child: CustomMultiChildLayout(
            delegate: _SliderLayoutDelegate(),
            children: <Widget>[
              LayoutId(
                id: _SliderChildSlot.sliderTrack,
                child: _SliderTrackObjectWidget(
                  ...
                ),
              ),
              LayoutId(
                id: _SliderChildSlot.sliderThumb,
                child: _SliderThumbObjectWidget(
                  ...
                ),
              ),
              LayoutId(
                id: _SliderChildSlot.sliderValueIndicator,
                child: _SliderValueIndicatorObjectWidget(
                  ...
                ),
              ),
            ],
          ),
        ),

This only works if _RenderSlider is processed before _RenderValueIndicator during PAINT. Otherwise, _RenderValueIndicator.paint will not see the painter configured by _RenderSlider.paint and instead paint with an outdated painter.

Would this also help this issue? Wouldn't this also ensure _RenderSlider is rendered before _RenderValueIndicator?

@TahaTesser
Copy link
Member

TahaTesser commented Oct 13, 2022

Fixing #111451, I noticed overlay issues in Slider, which makes M3 overlay tokens inconsistent and I also want add overlay support to RangeSlider so it can use M3 overlay tokens as well.

cc: @HansMuller

@TahaTesser TahaTesser self-assigned this May 4, 2023
@TahaTesser TahaTesser removed their assignment Jun 19, 2023
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

No branches or pull requests

3 participants