Commit 5ffc1d6
authored
Fix undefined behavior in screenshots on WASM (#22077)
# Objective
Currently the screenshot example on
https://bevy.org/examples/window/screenshot/ gives invalid PNG files
when I tried it. Looking at them they have some of the right bytes, but
also a bunch of garbage. The example works on native.
I narrowed it down to the one unsafe block in sight (thanks Rust!). I
don't fully understand why the code stopped working or if it was ever
valid, but in the meantime since it was written a safe API has been
added, and using it made the problem go away.
## Solution
Bump `js-sys`, use the safe API.
## Testing
I ran the example with `bevy run --example screenshot web`1 parent 6684682 commit 5ffc1d6
2 files changed
+8
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
159 | 161 | | |
160 | 162 | | |
161 | 163 | | |
| |||
0 commit comments