Skip to content

Conversation

@LongCatIsLooong
Copy link
Contributor

@LongCatIsLooong LongCatIsLooong commented Dec 9, 2024

The equality of 2 SystemTextScaler is determined by the platform's textScaleFactor scalar, because the scale method is always monotonically increasing wrt textScaleFactor.
On Android the scalar reflects the user configuration in system preference it seems: https://developer.android.com/reference/android/content/res/Configuration#fontScale

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. labels Dec 9, 2024
@Piinks
Copy link
Contributor

Piinks commented Feb 26, 2025

(Triage) Confirmed with @LongCatIsLooong this is still on their radar

github-merge-queue bot pushed a commit that referenced this pull request Mar 3, 2025
This is for #159999. That PR
breaks registered tests so a new matcher is added for soft transition &
making it slightly easier to write tests that verify nothing is
shadowing the system text scaler in the widget tree.

If this approach sounds plausible & gets merged, I'm going to:
1. remake the breaking change announcement 
2. update the migration guide with the new matcher,
3. migrate the registered tests and mark #159999 as ready for review.

## Pre-launch Checklist

- [ ] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [ ] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [ ] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [ ] I signed the [CLA].
- [ ] I listed at least one issue that this PR fixes in the description
above.
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [ ] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [ ] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [ ] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
@github-actions github-actions bot added f: material design flutter/packages/flutter/material repository. f: scrolling Viewports, list views, slivers, etc. labels Mar 19, 2025
@LongCatIsLooong LongCatIsLooong marked this pull request as ready for review March 19, 2025 23:12
chrisbobbe pushed a commit to LongCatIsLooong/zulip-flutter that referenced this pull request Mar 19, 2025
Flutter PR
  flutter/flutter#159999
(fixing a bug where MediaQuery provides an incorrect TextScaler)
breaks this test; fix it with isSystemTextScaler.

[chris: rewrote commit message; used package:legacy_checks]
chrisbobbe added a commit to LongCatIsLooong/zulip-flutter that referenced this pull request Mar 19, 2025
Flutter PR
  flutter/flutter#159999
(fixing a bug where MediaQuery provides an incorrect TextScaler)
breaks this test; fix it with isSystemTextScaler.

Co-authored-by: Chris Bobbe <[email protected]>
if (identical(this, other)) {
return true;
}
assert(minScale < maxScale);
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is the only place to enforce this constraint, we should do it where these two values are set instead. a crash here won't help us much in tracing down the bug

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is enforced in the (private) constructor (if minScale == maxScale the public API will return a different type of TextScaler). The assert is to indicate this is a valid assumption one can make for readers. Does it make more sense to make this a code comment then?

Copy link
Contributor

Choose a reason for hiding this comment

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

as long as there is not the first fail safe point, I am fine either way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also fine either way, but maybe a comment is better to avoid the confusion that started this thread.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the assert.

minScale == maxScale ? minScale.hashCode : Object.hash(scaler, minScale, maxScale);

@override
String toString() => '$scaler clamped [$minScale, $maxScale]';
Copy link
Contributor

Choose a reason for hiding this comment

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

consider use Diagnosticable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That doesn't seem to reduce the amount of code I have to write, are there other benefits of using Diagnosticable?

Copy link
Contributor

Choose a reason for hiding this comment

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

it provide a better api to fill in properties for printing the string representation. Besides that, I think devtools uses that api to get details about an object, but i am not too familiar with that part of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is what it looks like now:

'│└RichText(softWrap: wrapping at box width, textScaler: SystemTextScaler (no scaling), maxLines: unlimited, text: "A", dependencies: [Directionality], renderObject: RenderParagraph#00000 relayoutBoundary=up1)\n'

So that still works. I'd keep the class hierarchy simple for now in case someone wants to implement the class instead of extending.

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah makes sense

Copy link
Contributor

Choose a reason for hiding this comment

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

For my own understanding I wonder if @kenzieschmoll has any thoughts on when to use Diagnosticable in cases like this? I've wondered about this before.

@github-actions github-actions bot added the d: examples Sample code and demos label Mar 24, 2025
@LongCatIsLooong
Copy link
Contributor Author

@chunhtai @justinmc made a few changes after your last LGTM (diff). Does this still LGTY?

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Renewing my LGTM 👍

)
double textScaleFactor = 1.0,
TextScaler textScaler = TextScaler.noScaling,
TextScaler textScaler = const _UnspecifiedTextScaler(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent use of the sentinel pattern 💂

SystemTextScaler(:final double textScaleFactor) => this.textScaleFactor == textScaleFactor,
// When textScaleFactor is 1.0, the two TextScalers are extensionally
// equivalent.
TextScaler.noScaling => textScaleFactor == 1.0,
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch.

@matanlurey matanlurey removed their request for review April 2, 2025 15:28
@dkwingsmt
Copy link
Contributor

There are two Google test failures and are flakes. There are also a conflict.

@LongCatIsLooong
Copy link
Contributor Author

Waiting for my CL to land before merging this.

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label May 13, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 13, 2025
@auto-submit
Copy link
Contributor

auto-submit bot commented May 13, 2025

autosubmit label was removed for flutter/flutter/159999, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label.

@LongCatIsLooong LongCatIsLooong added the autosubmit Merge PR when tree becomes green via auto submit App label May 13, 2025
@auto-submit auto-submit bot added this pull request to the merge queue May 13, 2025
Merged via the queue into flutter:master with commit 30fe6e7 May 14, 2025
76 of 77 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label May 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request May 14, 2025
flutter/flutter@336a7ec...0b9f928

2025-05-14 [email protected] Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668)
2025-05-14 [email protected] Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794)
2025-05-14 [email protected] Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762)
2025-05-14 [email protected] Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754)
2025-05-14 [email protected] Add `titleAlignment` to `CheckboxListTile` and `RadioListTile`  (flutter/flutter#168666)
2025-05-14 [email protected] Remove deprecated todo about caching (flutter/flutter#168534)
2025-05-13 [email protected] Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949)
2025-05-13 [email protected] Improve documentation for KeyedSubtree constructor (flutter/flutter#167198)
2025-05-13 [email protected] Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999)
2025-05-13 [email protected] Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721)
2025-05-13 [email protected] [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771)
2025-05-13 [email protected] Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702)
2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775)
2025-05-13 [email protected] Use live region in error text input decorator for Android (flutter/flutter#165531)
2025-05-13 [email protected] [tool] Fix deprecated API calls within tool (flutter/flutter#168200)
2025-05-13 [email protected] Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510)
2025-05-13 [email protected] Fixes hero not shown when remove pages without animation (flutter/flutter#168617)
2025-05-13 [email protected] [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678)
2025-05-13 [email protected] Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400)
2025-05-13 [email protected] Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736)
2025-05-13 [email protected] [web] Fix multiline input selection in Chrome. (flutter/flutter#168217)
2025-05-13 [email protected] Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
@LongCatIsLooong LongCatIsLooong deleted the text-scaler branch May 14, 2025 16:14
FMorschel pushed a commit to FMorschel/packages that referenced this pull request Jun 9, 2025
…r#9251)

flutter/flutter@336a7ec...0b9f928

2025-05-14 [email protected] Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668)
2025-05-14 [email protected] Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794)
2025-05-14 [email protected] Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762)
2025-05-14 [email protected] Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754)
2025-05-14 [email protected] Add `titleAlignment` to `CheckboxListTile` and `RadioListTile`  (flutter/flutter#168666)
2025-05-14 [email protected] Remove deprecated todo about caching (flutter/flutter#168534)
2025-05-13 [email protected] Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949)
2025-05-13 [email protected] Improve documentation for KeyedSubtree constructor (flutter/flutter#167198)
2025-05-13 [email protected] Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999)
2025-05-13 [email protected] Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721)
2025-05-13 [email protected] [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771)
2025-05-13 [email protected] Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702)
2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775)
2025-05-13 [email protected] Use live region in error text input decorator for Android (flutter/flutter#165531)
2025-05-13 [email protected] [tool] Fix deprecated API calls within tool (flutter/flutter#168200)
2025-05-13 [email protected] Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510)
2025-05-13 [email protected] Fixes hero not shown when remove pages without animation (flutter/flutter#168617)
2025-05-13 [email protected] [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678)
2025-05-13 [email protected] Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400)
2025-05-13 [email protected] Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736)
2025-05-13 [email protected] [web] Fix multiline input selection in Chrome. (flutter/flutter#168217)
2025-05-13 [email protected] Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
Ortes pushed a commit to Ortes/packages that referenced this pull request Jun 25, 2025
…r#9251)

flutter/flutter@336a7ec...0b9f928

2025-05-14 [email protected] Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668)
2025-05-14 [email protected] Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794)
2025-05-14 [email protected] Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762)
2025-05-14 [email protected] Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754)
2025-05-14 [email protected] Add `titleAlignment` to `CheckboxListTile` and `RadioListTile`  (flutter/flutter#168666)
2025-05-14 [email protected] Remove deprecated todo about caching (flutter/flutter#168534)
2025-05-13 [email protected] Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949)
2025-05-13 [email protected] Improve documentation for KeyedSubtree constructor (flutter/flutter#167198)
2025-05-13 [email protected] Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999)
2025-05-13 [email protected] Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721)
2025-05-13 [email protected] [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771)
2025-05-13 [email protected] Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702)
2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775)
2025-05-13 [email protected] Use live region in error text input decorator for Android (flutter/flutter#165531)
2025-05-13 [email protected] [tool] Fix deprecated API calls within tool (flutter/flutter#168200)
2025-05-13 [email protected] Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510)
2025-05-13 [email protected] Fixes hero not shown when remove pages without animation (flutter/flutter#168617)
2025-05-13 [email protected] [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678)
2025-05-13 [email protected] Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400)
2025-05-13 [email protected] Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736)
2025-05-13 [email protected] [web] Fix multiline input selection in Chrome. (flutter/flutter#168217)
2025-05-13 [email protected] Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: 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
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 14, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 15, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: animation Animation APIs a: tests "flutter test", flutter_test, or one of our tests a: text input Entering text in a text field or keyboard related problems d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: cupertino flutter/packages/flutter/cupertino repository f: material design flutter/packages/flutter/material repository. f: routes Navigator, Router, and related APIs. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants