Skip to content

Implement getUniformMatX and getUniformMatXArray functionality on web#182249

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

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

Conversation

@walley892
Copy link
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
Member

/gemini review

Copy link
Contributor

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

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
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
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
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.

Copy link
Contributor

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

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.

Copy link
Member

@gaaclarke gaaclarke left a comment

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 [email protected]

flutter/flutter@6e4a481...c023e5b

2026-02-18 [email protected] [web] Pass form validation errors to screen readers via aria-description (flutter/flutter#180556)
2026-02-18 [email protected] Roll Packages from f83926f to 59f905c (10 revisions) (flutter/flutter#182547)
2026-02-18 [email protected] flutter_tools: Copy vendored frameworks from plugin podspecs in ios/macos-framework builds (flutter/flutter#180135)
2026-02-18 [email protected] Marks Windows framework_tests_misc_leak_tracking to be unflaky (flutter/flutter#182534)
2026-02-18 [email protected] Allow TabBar to receive a TabBarScrollController (flutter/flutter#180389)
2026-02-18 [email protected] 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 [email protected] Roll Fuchsia Linux SDK from mcN42vw48OPH3JDNm... to Ihau0pUz3u5ajw42u... (flutter/flutter#182530)
2026-02-18 [email protected] Analyzer, require 10.1.0, fix deprecations in dependency_graph.dart (flutter/flutter#182507)
2026-02-17 [email protected] Refactor: Remove material from actions test (flutter/flutter#181702)
2026-02-17 [email protected] [a11y] RangeSlider  mouse interaction should change keyboard focus (flutter/flutter#182185)
2026-02-17 [email protected] Remove more getters from userMessages class (flutter/flutter#182166)
2026-02-17 [email protected] Implement getUniformMatX and getUniformMatXArray functionality on web (flutter/flutter#182249)
2026-02-17 [email protected] Do not wait until dispose before removing replaced/popped page (flutter/flutter#182315)
2026-02-17 [email protected] Add contentTextStyle support to SimpleDialog (flutter/flutter#178824)
2026-02-17 [email protected] Filter error messages from `emulator -list-avds` output (flutter/flutter#180802)
2026-02-17 [email protected] [Reland] Cupertino cross imports (flutter/flutter#182416)
2026-02-17 [email protected] 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 [email protected],[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
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,
)
```
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