Skip to content

Add padding for color_plane widget for wasm/webgl compat#22724

Open
mitchty wants to merge 1 commit intobevyengine:mainfrom
mitchty:colorplane-wasm-fix
Open

Add padding for color_plane widget for wasm/webgl compat#22724
mitchty wants to merge 1 commit intobevyengine:mainfrom
mitchty:colorplane-wasm-fix

Conversation

@mitchty
Copy link

@mitchty mitchty commented Jan 27, 2026

Objective

  • Describe the objective or issue this PR addresses.
  • If you're fixing a specific issue, say "Fixes #X".

The new bevy feathers color plane widget throws out wgpu alignment issues for the f32 in use. To enable wasm builds to use this widget add padding similar to the existing shaders/materials.

Note this is my first contribution, I yolo'd names and whatnot so if the names I chose suck I can change them I'm not wedded to the names.

Solution

  • Describe the solution used to achieve the objective above.

Add a Vec3 padding to the uniform and material struct to pad to 16 bytes on wasm builds.

Testing

  • Did you test these changes? If so, how?

Yep built before/after in linux (wayland though I could test X if pressed), macos, and windows. Those all continued to work as expected as they did before. And tested in wasm on safari/firefox/chrome (mostly latest versions I think of those) where all 3 couldn't render the shader widget with this fix in place as a cargo patch its all good and works the same as the native builds.

  • Are there any parts that need more testing?

Maybe? I'm not sure I know enough to speak with any authority to that. I literally never program for the web this is all a fun side project in wasm for me and I honestly don't know if I did this jazz right or not. Real web programmers should yea/nay these bits I'm just a tourist.

  • How can other people (reviewers) test your changes? Is there anything specific they need to know?

Just test/build on wasm with the color widget in place. All I did was use cargo patch to point to the fixed version like so:

Same patch against 0.18.1 release branch:

bevy = { git = "https://github.com/mitchty/bevy", branch = "colorplane-wasm" }

This branch:

bevy = { git = "https://github.com/mitchty/bevy", branch = "colorplane-wasm-fix" }
  • If relevant, what platforms did you test these changes on, and are there any important ones you can't test?

I tried testing on all the systems I setup cross compilation for which is most of em methinks/mehopes.

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@rparrett
Copy link
Contributor

You can refer to #22357 for naming

@mitchty
Copy link
Author

mitchty commented Jan 27, 2026

Awesome I'll have a squizz later today when I get a chance and will mimic the correct naming convention thanks @rparrett ! I was more wondering what the uniform struct naming convention in wgsl is. I just guessed a terrible name hoping someone would tell me a better one.

Copy link
Contributor

@ickshonpe ickshonpe left a comment

Choose a reason for hiding this comment

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

Looks good, the crash is fixed, seems to run perfectly now.

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets labels Jan 27, 2026
@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Jan 27, 2026
@alice-i-cecile alice-i-cecile added this to the 0.18.1 milestone Jan 27, 2026
@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jan 27, 2026
@cart cart moved this from Needs SME Triage to SME Triaged in Rendering (2026 Proposal) Jan 28, 2026
@mitchty mitchty force-pushed the colorplane-wasm-fix branch from e91dd9b to 20644d7 Compare January 28, 2026 14:43
@mitchty
Copy link
Author

mitchty commented Jan 28, 2026

Ok updated the pr with the new names, and added bevy_feathers to bevy_internal for webgpu and webgl feature passing. The cfg attributes seem to work when I tested against bevy with webgl2 and webgpu with this fix in place still.

@mitchty mitchty force-pushed the colorplane-wasm-fix branch from 20644d7 to 8dc4ae6 Compare January 28, 2026 14:45
@mitchty mitchty force-pushed the colorplane-wasm-fix branch from 8dc4ae6 to b1650b6 Compare January 29, 2026 00:01
@mitchty
Copy link
Author

mitchty commented Feb 2, 2026

Not sure on the check-bans if its related to my adding feathers to bevy_internal or not or if I should go spelunking through dependency chains or not? The first iteration of this didn't hit this not sure what would cause it with a few rebases.

https://github.com/bevyengine/bevy/actions/runs/21460165775/job/61810538387?pr=22724#step:5:4825

error[duplicate]: found 2 duplicate entries for crate 'glam'
    ┌─ /home/runner/work/bevy/bevy/Cargo.lock:263:1
    │  
263 │ ╭ glam 0.30.10 registry+https://github.com/rust-lang/crates.io-index
264 │ │ glam 0.31.0 registry+https://github.com/rust-lang/crates.io-index
    │ ╰─────────────────────────────────────────────────────────────────┘ lock entries
    │  
    ├ glam v0.30.10
      └── dlss_wgpu v3.0.0
          └── bevy_anti_alias v0.19.0-dev
              ├── bevy_internal v0.19.0-dev
              │   ├── bevy v0.19.0-dev
              │   └── bevy_dylib v0.19.0-dev
              │       └── bevy v0.19.0-dev (*)
              └── bevy_solari v0.19.0-dev
                  └── bevy_internal v0.19.0-dev (*)
    ├ glam v0.31.0
      ├── bevy_math v0.19.0-dev

@ickshonpe
Copy link
Contributor

Not sure on the check-bans if its related to my adding feathers to bevy_internal or not or if I should go spelunking through dependency chains or not? The first iteration of this didn't hit this not sure what would cause it with a few rebases.

https://github.com/bevyengine/bevy/actions/runs/21460165775/job/61810538387?pr=22724#step:5:4825

error[duplicate]: found 2 duplicate entries for crate 'glam'
    ┌─ /home/runner/work/bevy/bevy/Cargo.lock:263:1
    │  
263 │ ╭ glam 0.30.10 registry+https://github.com/rust-lang/crates.io-index
264 │ │ glam 0.31.0 registry+https://github.com/rust-lang/crates.io-index
    │ ╰─────────────────────────────────────────────────────────────────┘ lock entries
    │  
    ├ glam v0.30.10
      └── dlss_wgpu v3.0.0
          └── bevy_anti_alias v0.19.0-dev
              ├── bevy_internal v0.19.0-dev
              │   ├── bevy v0.19.0-dev
              │   └── bevy_dylib v0.19.0-dev
              │       └── bevy v0.19.0-dev (*)
              └── bevy_solari v0.19.0-dev
                  └── bevy_internal v0.19.0-dev (*)
    ├ glam v0.31.0
      ├── bevy_math v0.19.0-dev

It's nothing you did.

I think this should fix itself if you just merge this PR with main, hopefully.

Added bevy_feathers to webgpu and webgl cargo feature passing.
@mitchty mitchty force-pushed the colorplane-wasm-fix branch from b1650b6 to 4bfb255 Compare February 3, 2026 00:07
@mitchty
Copy link
Author

mitchty commented Feb 3, 2026

@ickshonpe Looks like that was it, though I rebased to origin/main so that last compare's a doozy 🫠 Lets see if something else breaks 🍿

@kfc35 kfc35 added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Feb 4, 2026
@kfc35 kfc35 added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Bug An unexpected or incorrect behavior D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: No status
Status: SME Triaged

Development

Successfully merging this pull request may close these issues.

6 participants