Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Don't panic when StandardMaterial normal_map hasn't loaded yet #5307

Conversation

ChristopherBiscardi
Copy link
Contributor

@ChristopherBiscardi ChristopherBiscardi commented Jul 13, 2022

Objective

This unwrap() in pbr_material.rs will be hit if a StandardMaterial normal_map image has not finished loading, resulting in an error message that is hard to debug.

Solution

This PR improves the error message including a potential indication of why the unwrap() could have panic'd by using expect() instead of unwrap().

This PR removes the panic by only proceeding if the image is found.


Changelog

Don't panic when StandardMaterial normal_map images have not finished loading.

This unwrap() in pbr_material.rs will be hit if the normal_map image has not finished loading, resulting in an error message that is hard to debug. This PR improves the error message including a potential indication of why the unwrap() could have panic'd.
@Nilirad Nilirad added A-Rendering Drawing game state to the screen C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Jul 13, 2022
@superdump
Copy link
Contributor

Move it inside an if let Some(texture) = images.get(self.normal_map_texture.as_ref().unwrap()) {} block rather than panicking. A texture not being loaded yet shouldn't cause a panic.

@ChristopherBiscardi
Copy link
Contributor Author

makes sense to me, that's what I did to debug it in the first place. Updated the PR.

@mockersf mockersf added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jul 15, 2022
@alice-i-cecile
Copy link
Member

@ChristopherBiscardi please update the PR title to better reflect the changes (they get used as our commit titles). Once that's done, ping me and I'll merge it.

@ChristopherBiscardi ChristopherBiscardi changed the title Improve StandardMaterial normal_map error message Don't panic when StandardMaterial normal_map hasn't loaded yet Jul 16, 2022
@ChristopherBiscardi
Copy link
Contributor Author

@alice-i-cecile Done. Does this title work?

@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request Jul 16, 2022
# Objective

[This unwrap()](https://github.com/bevyengine/bevy/blob/de484c1e4147d01bf34c88a10797b75128a0d98a/crates/bevy_pbr/src/pbr_material.rs#L195) in pbr_material.rs will be hit if a StandardMaterial normal_map image has not finished loading, resulting in an error message that is hard to debug.

## Solution

~~This PR improves the error message including a potential indication of why the unwrap() could have panic'd by using expect() instead of unwrap().~~

This PR removes the panic by only proceeding if the image is found.

---

## Changelog

Don't panic when StandardMaterial normal_map images have not finished loading.
@bors bors bot changed the title Don't panic when StandardMaterial normal_map hasn't loaded yet [Merged by Bors] - Don't panic when StandardMaterial normal_map hasn't loaded yet Jul 16, 2022
@bors bors bot closed this Jul 16, 2022
inodentry pushed a commit to IyesGames/bevy that referenced this pull request Aug 8, 2022
…ngine#5307)

# Objective

[This unwrap()](https://github.com/bevyengine/bevy/blob/de484c1e4147d01bf34c88a10797b75128a0d98a/crates/bevy_pbr/src/pbr_material.rs#L195) in pbr_material.rs will be hit if a StandardMaterial normal_map image has not finished loading, resulting in an error message that is hard to debug.

## Solution

~~This PR improves the error message including a potential indication of why the unwrap() could have panic'd by using expect() instead of unwrap().~~

This PR removes the panic by only proceeding if the image is found.

---

## Changelog

Don't panic when StandardMaterial normal_map images have not finished loading.
james7132 pushed a commit to james7132/bevy that referenced this pull request Oct 28, 2022
…ngine#5307)

# Objective

[This unwrap()](https://github.com/bevyengine/bevy/blob/de484c1e4147d01bf34c88a10797b75128a0d98a/crates/bevy_pbr/src/pbr_material.rs#L195) in pbr_material.rs will be hit if a StandardMaterial normal_map image has not finished loading, resulting in an error message that is hard to debug.

## Solution

~~This PR improves the error message including a potential indication of why the unwrap() could have panic'd by using expect() instead of unwrap().~~

This PR removes the panic by only proceeding if the image is found.

---

## Changelog

Don't panic when StandardMaterial normal_map images have not finished loading.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
…ngine#5307)

# Objective

[This unwrap()](https://github.com/bevyengine/bevy/blob/de484c1e4147d01bf34c88a10797b75128a0d98a/crates/bevy_pbr/src/pbr_material.rs#L195) in pbr_material.rs will be hit if a StandardMaterial normal_map image has not finished loading, resulting in an error message that is hard to debug.

## Solution

~~This PR improves the error message including a potential indication of why the unwrap() could have panic'd by using expect() instead of unwrap().~~

This PR removes the panic by only proceeding if the image is found.

---

## Changelog

Don't panic when StandardMaterial normal_map images have not finished loading.
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-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants