Skip to content

Conversation

@gaodi-sec
Copy link
Contributor

@gaodi-sec gaodi-sec commented Jun 4, 2025

This PR exposes the renderStrategy property from the vector_graphics package to address the performance issue discussed in #166184.

By default, SVG widgets are rendered using the picture strategy, which records a list of drawing commands and replays them each frame. While this offers greater flexibility (e.g., for scaling), it can result in significant raster time when many SVGs are present in the widget tree.

As demonstrated in #166184, using the default strategy can lead to frame drops due to high raster time:

image

Switching to the raster strategy renders the SVGs into images ahead of time, reducing the raster workload:

image

Exposing this property allows developers to choose between flexibility and performance based on their app’s needs.

Fixes flutter/flutter#166184

Pre-Review Checklist

@SAGARSURI
Copy link

Looking forward to this getting merged asap! 🎉

@gaodi-sec gaodi-sec force-pushed the add_rendering_strategy branch from 4a2a0bd to f0da9b2 Compare June 6, 2025 02:07
Copy link
Contributor

@domesticmouse domesticmouse left a comment

Choose a reason for hiding this comment

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

LGTM once text is reformatted

@gaodi-sec gaodi-sec force-pushed the add_rendering_strategy branch from f0da9b2 to b5980ba Compare June 6, 2025 08:19
@domesticmouse
Copy link
Contributor

domesticmouse commented Jun 7, 2025

@stuartmorgan-g any idea why Linux CI is failing?

@stuartmorgan-g
Copy link
Collaborator

As it says in the failure output:

When bumping the version for release, the NEXT section should be incorporated into the new version's release notes.

See also https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#updating-a-changelog-that-has-a-next

@gaodi-sec
Copy link
Contributor Author

What should I do about this failure? Should I remove the Next section and append it to this PR?

@lanxuan365
Copy link

@stuartmorgan-g @domesticmouse Are there any further changes needed for this PR? Could you advise on how to deal with the “NEXT” tag and version update in the changelog? We are very interested in the performance improvements this change brings. Thank you very much!

@stuartmorgan-g
Copy link
Collaborator

Are there any further changes needed for this PR?

Yes. Please see my previous comment. PRs cannot land with CI failures.

Could you advise on how to deal with the “NEXT” tag and version update in the changelog?

I quoted the error message with instructions, and linked to our documentation on what the update needs to look like; I'm not sure what other information I can provide.

@gaodi-sec gaodi-sec force-pushed the add_rendering_strategy branch 2 times, most recently from 43c73f2 to 20a8e4c Compare June 12, 2025 11:23
@gaodi-sec gaodi-sec force-pushed the add_rendering_strategy branch from 20a8e4c to d7ce13c Compare June 13, 2025 01:53
@SAGARSURI

This comment was marked as off-topic.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 13, 2025
@auto-submit auto-submit bot merged commit c5ab57a into flutter:main Jun 13, 2025
80 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 13, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 13, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jun 13, 2025
flutter/packages@6d3aaf4...c5ab57a

2025-06-13 [email protected] [flutter_svg]
feat: Expose the renderStrategy property in SvgPicture
(flutter/packages#9373)
2025-06-12 [email protected] [go_router] Add routing functions to
GoRouteData (flutter/packages#9277)
2025-06-12 [email protected] [various] Update example apps to
Swift (flutter/packages#9347)
2025-06-12 [email protected] Roll Flutter from
824868f to f79452e (94 revisions) (flutter/packages#9419)
2025-06-12 [email protected]
[android_camera_camerax] Fix incorrect camera mirroring for front
cameras on devices using `ImageReader` Impeller backend
(flutter/packages#9233)

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-flutter-autoroll
Please CC [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
Ortes pushed a commit to Ortes/packages that referenced this pull request Jun 25, 2025
…lutter#9373)

This PR exposes the `renderStrategy` property from the `vector_graphics` package to address the performance issue discussed in [#166184](flutter/flutter#166184).

By default, SVG widgets are rendered using the picture strategy, which records a list of drawing commands and replays them each frame. While this offers greater flexibility (e.g., for scaling), it can result in significant raster time when many SVGs are present in the widget tree.

As demonstrated in [#166184](flutter/flutter#166184), using the default strategy can lead to frame drops due to high raster time:

<img width="820" alt="image" src="https://github.com/user-attachments/assets/dfc58d50-c8b2-477e-9a75-fe0eb742f9c7" />

Switching to the raster strategy renders the SVGs into images ahead of time, reducing the raster workload:

<img width="894" alt="image" src="https://github.com/user-attachments/assets/2fd8ddbf-3693-4797-be99-8b0919ef1703" />

Exposing this property allows developers to choose between flexibility and performance based on their app’s needs.

Fixes flutter/flutter#166184

## Pre-Review Checklist
mboetger pushed a commit to mboetger/flutter that referenced this pull request Jul 21, 2025
flutter/packages@6d3aaf4...c5ab57a

2025-06-13 [email protected] [flutter_svg]
feat: Expose the renderStrategy property in SvgPicture
(flutter/packages#9373)
2025-06-12 [email protected] [go_router] Add routing functions to
GoRouteData (flutter/packages#9277)
2025-06-12 [email protected] [various] Update example apps to
Swift (flutter/packages#9347)
2025-06-12 [email protected] Roll Flutter from
824868f to f79452e (94 revisions) (flutter/packages#9419)
2025-06-12 [email protected]
[android_camera_camerax] Fix incorrect camera mirroring for front
cameras on devices using `ImageReader` Impeller backend
(flutter/packages#9233)

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-flutter-autoroll
Please CC [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
vashworth pushed a commit to vashworth/packages that referenced this pull request Jul 30, 2025
…lutter#9373)

This PR exposes the `renderStrategy` property from the `vector_graphics` package to address the performance issue discussed in [#166184](flutter/flutter#166184).

By default, SVG widgets are rendered using the picture strategy, which records a list of drawing commands and replays them each frame. While this offers greater flexibility (e.g., for scaling), it can result in significant raster time when many SVGs are present in the widget tree.

As demonstrated in [#166184](flutter/flutter#166184), using the default strategy can lead to frame drops due to high raster time:

<img width="820" alt="image" src="https://github.com/user-attachments/assets/dfc58d50-c8b2-477e-9a75-fe0eb742f9c7" />

Switching to the raster strategy renders the SVGs into images ahead of time, reducing the raster workload:

<img width="894" alt="image" src="https://github.com/user-attachments/assets/2fd8ddbf-3693-4797-be99-8b0919ef1703" />

Exposing this property allows developers to choose between flexibility and performance based on their app’s needs.

Fixes flutter/flutter#166184

## Pre-Review Checklist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: flutter_svg

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[vector_graphics] Add support for automatic render strategy selection

5 participants