Skip to content

Conversation

@Hixie
Copy link
Contributor

@Hixie Hixie commented Nov 22, 2023

Fixes #105120

I also exposed the relevant dart:ui types which had the effect of removing a large number of dart:ui imports from examples.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Nov 22, 2023
@Hixie
Copy link
Contributor Author

Hixie commented Nov 24, 2023

flutter/packages#5471 should address the flutter_plugins issue

Hixie added a commit to Hixie/packages that referenced this pull request Nov 28, 2023
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Nov 28, 2023
Copy link
Contributor

Choose a reason for hiding this comment

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

"that have discrete values"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, good catch. fixed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a legitimate use case to allow duplicates? If not I think we should assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we want to assert on duplicates, that's probably something for the engine side. It would be weird to assert here, since there's nothing about the API today that disallows asserts.

I don't have a strong opinion on whether duplicates should be allowed or not.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok TextStyle's constructor is const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah that's probably the reason we went with this design

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the spec it looks like currently there're only 5 registered axes. Wouldn't it be faster to use regular element look up in a nested loop (or even sort the 2 lists), than doing the allocations ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Allocations are very cheap in Dart (it just bumps a pointer on the new generation heap).
I think if we expect this codepath to be used frequently enough that we care about performance, we should probably benchmark the various options, though. I don't know what the optimal path is. (I spent some time trying to figure it out, but nothing obvious came to mind.) In practice, I expect most cases will be either empty on one side and not the other (which has a fast path already), or the same order on both sides (which also has a fast path). There's not much benefit to lerping between two different lists (they would just step-function at t=0.5), and if the lists are the same, then it'd be much better for the values to be sorted by the developer than here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Allocations are very cheap in Dart (it just bumps a pointer on the new generation heap).

Ah TIL but surely setting up the HashSet/Map isn't going to be as trivial right?

I think if we expect this codepath to be used frequently enough that we care about performance, we should probably benchmark the various options

My question was mostly prompted by the O(N) claim in the documentation and the following paragraphs that describe the performance characteristics, and the fast path in the implementation, all that seem to indicate this is performance critical.
If most common cases take the fast path then sgtm (but I found the use of O(N) here a bit misleading since that shows how well the algorithm scales with a large N but in practice the number of font variations in each list <= 5).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it's not trivial (hence the paragraph in the documentation about it). I agree that the constant factors are probably much more important here than the scaling factor. I'll add some more text to that effect to the docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to have a default value for each axis then? Like the weight defaults to 400 if one side is null? Or the developer should always make sure the axis pairs match if the lerp function is used for an animated transition?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fonts have a default value, but we have no way to find out what it is (because, for one, we don't know what font is going to be used, and it could be a different font for each character in the string, due to font fallbacks).

If the developer wants to animate something, they'll specify both ends, in practice.

Copy link
Contributor

@LongCatIsLooong LongCatIsLooong left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah ok TextStyle's constructor is const.

Copy link
Contributor

Choose a reason for hiding this comment

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

Allocations are very cheap in Dart (it just bumps a pointer on the new generation heap).

Ah TIL but surely setting up the HashSet/Map isn't going to be as trivial right?

I think if we expect this codepath to be used frequently enough that we care about performance, we should probably benchmark the various options

My question was mostly prompted by the O(N) claim in the documentation and the following paragraphs that describe the performance characteristics, and the fast path in the implementation, all that seem to indicate this is performance critical.
If most common cases take the fast path then sgtm (but I found the use of O(N) here a bit misleading since that shows how well the algorithm scales with a large N but in practice the number of font variations in each list <= 5).

@Hixie Hixie added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 2, 2023
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 2, 2023
@auto-submit
Copy link
Contributor

auto-submit bot commented Dec 2, 2023

auto label is removed for flutter/flutter/138881, due to - The status or check suite Linux framework_tests_misc has failed. Please fix the issues identified (or deflake) before re-applying this label.

@github-actions github-actions bot removed a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Dec 5, 2023
Fixes flutter#105120

I also exposed the relevant dart:ui types which had the effect of removing a large number of dart:ui imports from examples.
@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Dec 6, 2023
@Hixie Hixie added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 7, 2023
@auto-submit auto-submit bot merged commit c674161 into flutter:master Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fontVariations property is not animatable within AnimatedDefaultTextStyle

2 participants