Skip to content

Implement getUniformMatX and getUniformMatXArray functionality on web#182249

Merged
auto-submit[bot] merged 3 commits into
flutter:masterfrom
walley892:get-matrix-web
Feb 17, 2026
Merged

Implement getUniformMatX and getUniformMatXArray functionality on web#182249
auto-submit[bot] merged 3 commits into
flutter:masterfrom
walley892:get-matrix-web

Conversation

@walley892

Copy link
Copy Markdown
Contributor

What it says on the tin.

Implementes getUniformMat2, getUniformMat3, getUniformMat4, getUniformMat2Array, getUniformMat3Array, and getUniformMat4Array on the web. This will allow users to get matrix uniforms by name.

Also adds tests for existing matrix functionality on web.

Before:

setFloat(0, 1.0);
setFloat(1, 0.0);
setFloat(2, 0.0);
setFloat(3, 1.0);

After:

shader.getUniformMat2('uIdentity').set(
    1.0, 0.0,
    0.0, 1.0,
)

@walley892 walley892 requested a review from gaaclarke February 11, 2026 22:02
@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. platform-web Web applications specifically labels Feb 11, 2026
@gaaclarke

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements getUniformMatX and getUniformMatXArray functionality for web, which was previously unsupported. The changes involve adding implementations in both canvaskit and skwasm backends, along with corresponding tests. My review has identified a critical issue in the implementation of the set methods for all new matrix slot classes (_CkUniformMat*Slot and _SkwasmUniformMat*Slot). These methods incorrectly transpose the matrices, which will lead to incorrect rendering when these matrices are used for transformations. The provided tests are not sufficient to catch this bug. I have provided suggestions to fix this critical issue. Additionally, I've made a medium-severity suggestion to improve the organization of the new tests for better maintainability.

Comment on lines +695 to +700
void set(double m00, double m01, double m10, double m11) {
_m00.set(m00);
_m01.set(m01);
_m10.set(m10);
_m11.set(m11);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

critical

The implementation of set for _CkUniformMat2Slot incorrectly transposes the matrix. The set method's parameters are in row-major order, but they are being mapped incorrectly to the underlying column-major uniform buffer. This happens because the internal fields (_m01, _m10) are confusingly named and assigned from the column-major slot list. This will cause incorrect rendering for any shader that uses this matrix for transformations.

To fix this, the set method should correctly map the row-major arguments to the appropriate column-major slots in the uniform buffer.

Suggested change
void set(double m00, double m01, double m10, double m11) {
_m00.set(m00);
_m01.set(m01);
_m10.set(m10);
_m11.set(m11);
}
void set(double m00, double m01, double m10, double m11) {
_m00.set(m00);
_m01.set(m10);
_m10.set(m01);
_m11.set(m11);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure this is the case, the bot may be mixing up the meaning of the first number versus the second number. That may mean it's worth adding a comment what the first and second number mean (row vs col).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, I was confused. I didn't realize that in GLSL, uMat2[i] referred to the ith column, not the ith row. I was grabbing n*n contiguous memory slots and just assumed row-major ordering. It was always in column-major order, but the parameter names and instance variable names didn't reflect that.

The bot's code suggestion is confusing, I just updated the names to be less confusing.

Comment thread engine/src/flutter/lib/web_ui/lib/src/engine/skwasm/skwasm_impl/shaders.dart Outdated
Comment thread engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request implements getUniformMatX and getUniformMatXArray functionality for web, which was previously unsupported. The changes are implemented for both CanvasKit and Skwasm backends, along with corresponding tests. The implementation has a critical bug in how matrix uniforms are handled, where they are passed in row-major order instead of the expected column-major order. I've provided suggestions to fix this bug and refactor the code for better maintainability. Additionally, I've suggested improvements to the new tests for readability and pointed out that some tests will need to be updated after the matrix layout bug is fixed.

Comment thread engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart
Comment thread engine/src/flutter/lib/web_ui/test/ui/fragment_shader_test.dart

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lgtm, I assume that the bot is confused about row-major vs col-major. Please double check it. I think we should add a comment before all the _mXX instance variables to explicitly state what the first and second number mean.

@walley892 walley892 added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 17, 2026
@auto-submit auto-submit Bot added this pull request to the merge queue Feb 17, 2026
Merged via the queue into flutter:master with commit 8f61855 Feb 17, 2026
180 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 17, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Feb 18, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Feb 18, 2026
…11060)

Manual roll requested by tarrinneal@google.com

flutter/flutter@6e4a481...c023e5b

2026-02-18 zhongliu88889@gmail.com [web] Pass form validation errors to screen readers via aria-description (flutter/flutter#180556)
2026-02-18 engine-flutter-autoroll@skia.org Roll Packages from f83926f to 59f905c (10 revisions) (flutter/flutter#182547)
2026-02-18 104147021+MohammedTarigg@users.noreply.github.com flutter_tools: Copy vendored frameworks from plugin podspecs in ios/macos-framework builds (flutter/flutter#180135)
2026-02-18 fluttergithubbot@gmail.com Marks Windows framework_tests_misc_leak_tracking to be unflaky (flutter/flutter#182534)
2026-02-18 brackenavaron@gmail.com Allow TabBar to receive a TabBarScrollController (flutter/flutter#180389)
2026-02-18 brackenavaron@gmail.com Clean up cross imports in single_child_scroll_view_test.dart, decorated_sliver_test.dart, draggable_scrollable_sheet_test.dart (flutter/flutter#181613)
2026-02-18 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from mcN42vw48OPH3JDNm... to Ihau0pUz3u5ajw42u... (flutter/flutter#182530)
2026-02-18 scheglov@google.com Analyzer, require 10.1.0, fix deprecations in dependency_graph.dart (flutter/flutter#182507)
2026-02-17 34465683+rkishan516@users.noreply.github.com Refactor: Remove material from actions test (flutter/flutter#181702)
2026-02-17 jhy03261997@gmail.com [a11y] RangeSlider  mouse interaction should change keyboard focus (flutter/flutter#182185)
2026-02-17 116356835+AbdeMohlbi@users.noreply.github.com Remove more getters from userMessages class (flutter/flutter#182166)
2026-02-17 evanwall@buffalo.edu Implement getUniformMatX and getUniformMatXArray functionality on web (flutter/flutter#182249)
2026-02-17 victorsanniay@gmail.com Do not wait until dispose before removing replaced/popped page (flutter/flutter#182315)
2026-02-17 iliyazelenkog@gmail.com Add contentTextStyle support to SimpleDialog (flutter/flutter#178824)
2026-02-17 alex.medinsh@gmail.com Filter error messages from `emulator -list-avds` output (flutter/flutter#180802)
2026-02-17 brackenavaron@gmail.com [Reland] Cupertino cross imports (flutter/flutter#182416)
2026-02-17 engine-flutter-autoroll@skia.org Roll Packages from 09104b0 to f83926f (1 revision) (flutter/flutter#182504)

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 stuartmorgan@google.com,tarrinneal@google.com 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
rickhohler pushed a commit to rickhohler/flutter that referenced this pull request Feb 19, 2026
…flutter#182249)

What it says on the tin.

Implementes getUniformMat2, getUniformMat3, getUniformMat4,
getUniformMat2Array, getUniformMat3Array, and getUniformMat4Array on the
web. This will allow users to get matrix uniforms by name.

Also adds tests for existing matrix functionality on web.

Before:
```dart
setFloat(0, 1.0);
setFloat(1, 0.0);
setFloat(2, 0.0);
setFloat(3, 1.0);
```

After:
```
shader.getUniformMat2('uIdentity').set(
    1.0, 0.0,
    0.0, 1.0,
)
```
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Feb 27, 2026
…flutter#182249)

What it says on the tin.

Implementes getUniformMat2, getUniformMat3, getUniformMat4,
getUniformMat2Array, getUniformMat3Array, and getUniformMat4Array on the
web. This will allow users to get matrix uniforms by name.

Also adds tests for existing matrix functionality on web.

Before:
```dart
setFloat(0, 1.0);
setFloat(1, 0.0);
setFloat(2, 0.0);
setFloat(3, 1.0);
```

After:
```
shader.getUniformMat2('uIdentity').set(
    1.0, 0.0,
    0.0, 1.0,
)
```
okorohelijah pushed a commit to okorohelijah/packages that referenced this pull request Mar 26, 2026
…lutter#11060)

Manual roll requested by tarrinneal@google.com

flutter/flutter@6e4a481...c023e5b

2026-02-18 zhongliu88889@gmail.com [web] Pass form validation errors to screen readers via aria-description (flutter/flutter#180556)
2026-02-18 engine-flutter-autoroll@skia.org Roll Packages from f83926f to 59f905c (10 revisions) (flutter/flutter#182547)
2026-02-18 104147021+MohammedTarigg@users.noreply.github.com flutter_tools: Copy vendored frameworks from plugin podspecs in ios/macos-framework builds (flutter/flutter#180135)
2026-02-18 fluttergithubbot@gmail.com Marks Windows framework_tests_misc_leak_tracking to be unflaky (flutter/flutter#182534)
2026-02-18 brackenavaron@gmail.com Allow TabBar to receive a TabBarScrollController (flutter/flutter#180389)
2026-02-18 brackenavaron@gmail.com Clean up cross imports in single_child_scroll_view_test.dart, decorated_sliver_test.dart, draggable_scrollable_sheet_test.dart (flutter/flutter#181613)
2026-02-18 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from mcN42vw48OPH3JDNm... to Ihau0pUz3u5ajw42u... (flutter/flutter#182530)
2026-02-18 scheglov@google.com Analyzer, require 10.1.0, fix deprecations in dependency_graph.dart (flutter/flutter#182507)
2026-02-17 34465683+rkishan516@users.noreply.github.com Refactor: Remove material from actions test (flutter/flutter#181702)
2026-02-17 jhy03261997@gmail.com [a11y] RangeSlider  mouse interaction should change keyboard focus (flutter/flutter#182185)
2026-02-17 116356835+AbdeMohlbi@users.noreply.github.com Remove more getters from userMessages class (flutter/flutter#182166)
2026-02-17 evanwall@buffalo.edu Implement getUniformMatX and getUniformMatXArray functionality on web (flutter/flutter#182249)
2026-02-17 victorsanniay@gmail.com Do not wait until dispose before removing replaced/popped page (flutter/flutter#182315)
2026-02-17 iliyazelenkog@gmail.com Add contentTextStyle support to SimpleDialog (flutter/flutter#178824)
2026-02-17 alex.medinsh@gmail.com Filter error messages from `emulator -list-avds` output (flutter/flutter#180802)
2026-02-17 brackenavaron@gmail.com [Reland] Cupertino cross imports (flutter/flutter#182416)
2026-02-17 engine-flutter-autoroll@skia.org Roll Packages from 09104b0 to f83926f (1 revision) (flutter/flutter#182504)

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 stuartmorgan@google.com,tarrinneal@google.com 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
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…flutter#182249)

What it says on the tin.

Implementes getUniformMat2, getUniformMat3, getUniformMat4,
getUniformMat2Array, getUniformMat3Array, and getUniformMat4Array on the
web. This will allow users to get matrix uniforms by name.

Also adds tests for existing matrix functionality on web.

Before:
```dart
setFloat(0, 1.0);
setFloat(1, 0.0);
setFloat(2, 0.0);
setFloat(3, 1.0);
```

After:
```
shader.getUniformMat2('uIdentity').set(
    1.0, 0.0,
    0.0, 1.0,
)
```
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…lutter#11060)

Manual roll requested by tarrinneal@google.com

flutter/flutter@6e4a481...c023e5b

2026-02-18 zhongliu88889@gmail.com [web] Pass form validation errors to screen readers via aria-description (flutter/flutter#180556)
2026-02-18 engine-flutter-autoroll@skia.org Roll Packages from f83926f to 59f905c (10 revisions) (flutter/flutter#182547)
2026-02-18 104147021+MohammedTarigg@users.noreply.github.com flutter_tools: Copy vendored frameworks from plugin podspecs in ios/macos-framework builds (flutter/flutter#180135)
2026-02-18 fluttergithubbot@gmail.com Marks Windows framework_tests_misc_leak_tracking to be unflaky (flutter/flutter#182534)
2026-02-18 brackenavaron@gmail.com Allow TabBar to receive a TabBarScrollController (flutter/flutter#180389)
2026-02-18 brackenavaron@gmail.com Clean up cross imports in single_child_scroll_view_test.dart, decorated_sliver_test.dart, draggable_scrollable_sheet_test.dart (flutter/flutter#181613)
2026-02-18 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from mcN42vw48OPH3JDNm... to Ihau0pUz3u5ajw42u... (flutter/flutter#182530)
2026-02-18 scheglov@google.com Analyzer, require 10.1.0, fix deprecations in dependency_graph.dart (flutter/flutter#182507)
2026-02-17 34465683+rkishan516@users.noreply.github.com Refactor: Remove material from actions test (flutter/flutter#181702)
2026-02-17 jhy03261997@gmail.com [a11y] RangeSlider  mouse interaction should change keyboard focus (flutter/flutter#182185)
2026-02-17 116356835+AbdeMohlbi@users.noreply.github.com Remove more getters from userMessages class (flutter/flutter#182166)
2026-02-17 evanwall@buffalo.edu Implement getUniformMatX and getUniformMatXArray functionality on web (flutter/flutter#182249)
2026-02-17 victorsanniay@gmail.com Do not wait until dispose before removing replaced/popped page (flutter/flutter#182315)
2026-02-17 iliyazelenkog@gmail.com Add contentTextStyle support to SimpleDialog (flutter/flutter#178824)
2026-02-17 alex.medinsh@gmail.com Filter error messages from `emulator -list-avds` output (flutter/flutter#180802)
2026-02-17 brackenavaron@gmail.com [Reland] Cupertino cross imports (flutter/flutter#182416)
2026-02-17 engine-flutter-autoroll@skia.org Roll Packages from 09104b0 to f83926f (1 revision) (flutter/flutter#182504)

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 stuartmorgan@google.com,tarrinneal@google.com 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine flutter/engine related. See also e: labels. platform-web Web applications specifically

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants