Implement getUniformMatX and getUniformMatXArray functionality on web#182249
Conversation
|
/gemini review |
There was a problem hiding this comment.
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.
| void set(double m00, double m01, double m10, double m11) { | ||
| _m00.set(m00); | ||
| _m01.set(m01); | ||
| _m10.set(m10); | ||
| _m11.set(m11); | ||
| } |
There was a problem hiding this comment.
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.
| 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); | |
| } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
gaaclarke
left a comment
There was a problem hiding this comment.
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.
…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
…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, ) ```
…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, ) ```
…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
…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, ) ```
…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
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:
After: