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

Add error check for reflection probe invalid atlas index. #104302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

brennennen
Copy link
Contributor

@brennennen brennennen commented Mar 18, 2025

Potential fix for issue #104291

If there is more reflection probes in a scene than allowed in configurations (default is 64), then in reflection_probe_instance_get_framebuffer there is a case where we try to index an array with an atlas index of -1, which crashes the editor. This pull request fixes the crash and displays an error message instead.

@brennennen brennennen requested a review from a team as a code owner March 18, 2025 07:46
@brennennen brennennen force-pushed the reflection_probe_count_error_check branch from 99a95dd to cb25108 Compare March 18, 2025 08:17
@akien-mga
Copy link
Member

I'm not a rendering expert but adding another error check to prevent a crash seems good.

I suggest you amend the commit with the typo fix you identified in the issue:

"lightmap will nod display properly", i imagine this was supposed to be "not".

@akien-mga akien-mga added bug topic:rendering crash cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release labels Mar 18, 2025
@akien-mga akien-mga modified the milestones: 4.4, 4.5 Mar 18, 2025
@brennennen brennennen force-pushed the reflection_probe_count_error_check branch from cb25108 to 6215336 Compare March 18, 2025 13:32
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally, it works as expected.

Code looks good to me.

Note that error spam will occur while reflection probes attempt to re-render:

ERROR: Reflection probe atlas index invalid. Maximum amount of reflection probes in use (114) may have been exceeded, reflections will not display properly.
   at: reflection_probe_instance_get_framebuffer (./servers/rendering/renderer_rd/storage_rd/light_storage.cpp:1668)
ERROR: Parameter "framebuffer" is null.
   at: framebuffer_get_format (./servers/rendering/rendering_device.cpp:2921)
ERROR: Parameter "framebuffer" is null.
   at: draw_list_begin (./servers/rendering/rendering_device.cpp:4275)
ERROR: Condition "!draw_list.active" is true.
   at: draw_list_bind_uniform_set (./servers/rendering/rendering_device.cpp:4491)
ERROR: Condition "!draw_list.active" is true.
   at: draw_list_bind_uniform_set (./servers/rendering/rendering_device.cpp:4491)
ERROR: Condition "!draw_list.active" is true.
   at: draw_list_bind_uniform_set (./servers/rendering/rendering_device.cpp:4491)
ERROR: Immediate draw list is already inactive.
   at: draw_list_end (./servers/rendering/rendering_device.cpp:4954)
ERROR: Parameter "framebuffer" is null.
   at: draw_list_begin (./servers/rendering/rendering_device.cpp:4275)
ERROR: Parameter "framebuffer" is null.
   at: framebuffer_get_format (./servers/rendering/rendering_device.cpp:2921)
ERROR: Condition "!E" is true. Returning: TEXTURE_SAMPLES_1
   at: framebuffer_format_get_texture_samples (./servers/rendering/rendering_device.cpp:2768)
ERROR: Mismatch fragment shader output mask (1) and framebuffer color output mask (0) when binding both in render pipeline.
   at: render_pipeline_create (./servers/rendering/rendering_device.cpp:3873)

This can slow down the editor quite a bit with hundreds of probes in the scene.

@brennennen brennennen force-pushed the reflection_probe_count_error_check branch from 6215336 to d722d02 Compare March 18, 2025 20:51
@brennennen
Copy link
Contributor Author

brennennen commented Mar 18, 2025

I decided to test compatibility too and it has the same issue in a copy of a function with the same name. I fixed the issue in the same way as forward+, but it's still got issues and should be reviewed/discussed.

For compatibility, this fix removes a crash, so I figured it was worth still committing, but it hangs all ui rendering. It looks like maybe compatibility has less error handling down stream for a bad frame buffer handles than forward+ has and should probably be investigated further, either in this ticket or a spin off one.

EDIT: I've found a way to fix the crash and not cause a hang in compatibility, but it is a bit hacky. I've re-requested a review so this doesn't get merged without this new change being reviewed.

@brennennen brennennen force-pushed the reflection_probe_count_error_check branch from d722d02 to 08d83c7 Compare March 18, 2025 21:36
@brennennen brennennen requested a review from Calinou March 18, 2025 21:44
@brennennen brennennen force-pushed the reflection_probe_count_error_check branch 3 times, most recently from 94ca74c to 10bd968 Compare March 19, 2025 06:07
@brennennen
Copy link
Contributor Author

brennennen commented Mar 19, 2025

Alrighty, In finding a fix for compatibility (that wasn't a hack), I ended up going a route that used "reflection_probe_has_atlas_index" to bypass the branch that caused the crash and also not spam the error logs.

I tried to do this same thing for Forward+, but it didn't work, so I'm keeping the error spammy solution. I'm not sure how to finagle my way through the render_scene function to avoid the error spam log, but also not crash.

@brennennen brennennen force-pushed the reflection_probe_count_error_check branch 2 times, most recently from 9860eac to e6cc379 Compare March 19, 2025 06:57
@brennennen
Copy link
Contributor Author

brennennen commented Mar 19, 2025

Current behavioral changes from this pr as of the latest commit:

  • fixes a crash in forward/mobile/compatibility
  • for forward/mobile: when exceeding the maximum number of reflection probes configured, instead of crashing, logs many errors messages that will impact performance.
  • for compatibility: when exceeding the maximum number of reflection probes configured, silently ignores reflection probes past the maximum, no logs at all (which is also not ideal, probably want at least a warning).

@brennennen brennennen force-pushed the reflection_probe_count_error_check branch from e6cc379 to 341d2e9 Compare March 21, 2025 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cherrypick:4.4 Considered for cherry-picking into a future 4.4.x release crash topic:rendering
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants