Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jonahwilliams
Copy link
Contributor

@jonahwilliams jonahwilliams commented Sep 10, 2024

The Glyph color and stroke property are only required for stroked text or COLR text, in all other cases its a no-op. We can do the text hashing faster if we let these properties be optional.

Also as an experiment switches to absl containers which should be more reasonably performant than std containers. required more changes, will try again later

@jonahwilliams jonahwilliams marked this pull request as ready for review September 10, 2024 21:13
@jonahwilliams
Copy link
Contributor Author

Also moves some Hash/Eq methods to structs so we can be compatible with absl flat_hash_map

@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

Changes reported for pull request #55060 at sha 0fdf51e

@flutter-dashboard
Copy link

It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!).

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@jonahwilliams
Copy link
Contributor Author

I think since this is just a refactor of existing functionality, it should be test exempt. PR 2 in this list is not just a refactor and will have tests

@jonahwilliams jonahwilliams added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 11, 2024
@auto-submit auto-submit bot merged commit 38e37ce into flutter:main Sep 11, 2024
@jonahwilliams jonahwilliams deleted the add_descriptor_buffer branch September 11, 2024 18:17
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 11, 2024
jesswrd pushed a commit to jesswrd/engine that referenced this pull request Sep 11, 2024
…r#55060)

The Glyph color and stroke property are only required for stroked text or COLR text, in all other cases its a no-op. We can do the text hashing faster if we let these properties be optional.

~Also as an experiment switches to absl containers which should be more reasonably performant than std containers.~ required more changes, will try again later
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 11, 2024
…155046)

flutter/engine@ade8ef2...ee5adf6

2024-09-11 [email protected] Zip and upload Xcode xcresults on scenario test failure (flutter/engine#55093)
2024-09-11 [email protected] [Impeller] hash less text stuff per frame for text rendering. (flutter/engine#55060)

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

To file a bug in Flutter: 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
auto-submit bot pushed a commit that referenced this pull request Sep 27, 2024
Follow up to #55060

Currently we have multiple stages of hashing while font rendering, which is relatively expensive for the actualy required workload. First, we hash the contents of all text frames to compute the unique set of glyphs per frame. Then we diff this hash set against the hashmap of glyphs within the atlas. Finally we hash and lookup the final rendered bounds for each glyph.

We can simplify this to 2. hash lookups for glyphs not yet in the atlas and 1. hash lookup for glyphs that are in the atlas. This is done by combing the step where we uniquely compute glyphs per frame with the diff against the current atlas. When this lookup is performed, we also store the glyph position (if found) in the text_frame itself - which allows text contents to skip the last hash, as long as the glyph has already been rendered.

### Before

![flutter_03](https://github.com/user-attachments/assets/be9c4459-f0c8-426c-b152-38861acb207f)

### After

![flutter_04](https://github.com/user-attachments/assets/1aa7cbd1-6af7-4020-8966-7e3baaef102b)

Using this handy dandy test app:

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  Widget build(context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Platform View'),
        ),
        body: SafeArea(child: Stack(children: [
          SizedBox(
            width: 380,
            height: 380,
            child: LinearProgressIndicator(),
          ),
          Stack(
            children: List<Widget>.generate(1000, (index) {
              // The problem already happens with a small amount of widgets.
              // Using an excessive amount of widgets is just to make the problem more evident.
              return Text("Lots of Texts represent a Widget with complex components.");
            }),
          ),

          Align(
            alignment: Alignment.bottomCenter,
            child:
            TextButton(
              child: Text("Button"),
              onPressed: () {
                print("Tap ${DateTime.now()}");
              },
            ),
          ),
        ],
        ),
        ),
      ),
    );
  }
}
```
auto-submit bot added a commit that referenced this pull request Sep 27, 2024
Reverts: #55092
Initiated by: jonahwilliams
Reason for reverting: framework golden failures.
Original PR Author: jonahwilliams

Reviewed By: {chinmaygarde, jtmcdole}

This change reverts the following previous change:
Follow up to #55060

Currently we have multiple stages of hashing while font rendering, which is relatively expensive for the actualy required workload. First, we hash the contents of all text frames to compute the unique set of glyphs per frame. Then we diff this hash set against the hashmap of glyphs within the atlas. Finally we hash and lookup the final rendered bounds for each glyph.

We can simplify this to 2. hash lookups for glyphs not yet in the atlas and 1. hash lookup for glyphs that are in the atlas. This is done by combing the step where we uniquely compute glyphs per frame with the diff against the current atlas. When this lookup is performed, we also store the glyph position (if found) in the text_frame itself - which allows text contents to skip the last hash, as long as the glyph has already been rendered.

### Before

![flutter_03](https://github.com/user-attachments/assets/be9c4459-f0c8-426c-b152-38861acb207f)

### After

![flutter_04](https://github.com/user-attachments/assets/1aa7cbd1-6af7-4020-8966-7e3baaef102b)

Using this handy dandy test app:

```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  Widget build(context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Platform View'),
        ),
        body: SafeArea(child: Stack(children: [
          SizedBox(
            width: 380,
            height: 380,
            child: LinearProgressIndicator(),
          ),
          Stack(
            children: List<Widget>.generate(1000, (index) {
              // The problem already happens with a small amount of widgets.
              // Using an excessive amount of widgets is just to make the problem more evident.
              return Text("Lots of Texts represent a Widget with complex components.");
            }),
          ),

          Align(
            alignment: Alignment.bottomCenter,
            child:
            TextButton(
              child: Text("Button"),
              onPressed: () {
                print("Tap ${DateTime.now()}");
              },
            ),
          ),
        ],
        ),
        ),
      ),
    );
  }
}
```
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App e: impeller will affect goldens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants