Skip to content

Conversation

@mirsella
Copy link
Contributor

@mirsella mirsella commented Feb 11, 2026

follow up to #22414

in my comment #22414 (comment) i realized the warn added in #22414 would never actually trigger because pixel_bytes and pixel_bytes_mut were returning Option instead of Result, which caused the UnsupportedTextureFormat error to be lost and converted to OutOfBounds.

this changes:

  • pixel_data_offset now returns Result instead of Option
  • pixel_bytes and pixel_bytes_mut now return Result instead of Option
  • errors are properly propagated so the warn in sprite picking actually triggers for compressed textures
  • added a regression test compressed_texture_format_is_reported_correctly
  • updated examples/2d/cpu_draw.rs for the new signature

should i remove the regression test if it's useless ?

thanks

@mirsella
Copy link
Contributor Author

i can also add TextureAccessError::UnInitializated/NotLoaded (#22414 (comment)) if its a good pattern

@alice-i-cecile alice-i-cecile added C-Bug An unexpected or incorrect behavior A-Rendering Drawing game state to the screen S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Feb 11, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering (2026 Proposal) Feb 11, 2026
@alice-i-cecile alice-i-cecile requested a review from JMS55 February 11, 2026 18:04
@alice-i-cecile alice-i-cecile added the M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Feb 11, 2026
@github-actions
Copy link
Contributor

It looks like your PR is a breaking change, but you didn't provide a migration guide.

Please review the instructions for writing migration guides, then expand or revise the content in the migration guides directory to reflect your changes.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

Generally like this, and I think the regression test is fine. A few comments:

  1. Needs a simple migration guide.
  2. Can we flatten out the Result<Option return types? Is returning Ok(None) actually useful here, or should that just be a new kind of error? If we'd like to keep them, we should be very clear in the docs what Ok(None) means.

@mirsella
Copy link
Contributor Author

mirsella commented Feb 11, 2026

i think ive documented all functions with:

Returns Ok(None) if the image data is not initialized.

adding a new kind of error is what im proposing here

i can also add TextureAccessError::UnInitializated/NotLoaded (#22414 (comment)) if its a good pattern

so it can replace the Ok(None) if that's appropriate, i find this better too. what error variant name do you prefer ?

@alice-i-cecile
Copy link
Member

I prefer Unitialized: I think that NotLoaded implies that loading was started but not finished, which may or may not be true.

@mirsella
Copy link
Contributor Author

should be good now :)

… types

- Add TextureAccessError::Uninitialized variant for when image data is not initialized
- Change pixel_bytes from Result<Option<&[u8]>, _> to Result<&[u8], _>
- Change pixel_bytes_mut from Result<Option<&mut [u8]>, _> to Result<&mut [u8], _>
- Change pixel_data_offset from Result<Option<usize>, _> to Result<usize, _>
- Remove redundant return type commentary from rustdoc
- Update cpu_draw example for new API
- Update migration guide
@mirsella mirsella force-pushed the fix-image-pixel-access-error branch from 13f444c to cfd7222 Compare February 11, 2026 21:15
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 C-Bug An unexpected or incorrect behavior M-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

Status: No status
Status: Needs SME Triage

Development

Successfully merging this pull request may close these issues.

2 participants