backend: Propagate backend thread exceptions to the main thread.#9903
Merged
Conversation
ca10f61 to
de96432
Compare
de96432 to
32b6ea1
Compare
z3moon
reviewed
Apr 16, 2026
32b6ea1 to
98fd32c
Compare
poweifeng
approved these changes
Apr 17, 2026
Contributor
poweifeng
left a comment
There was a problem hiding this comment.
lgtm with nits and a question
bejado
requested changes
Apr 17, 2026
Member
bejado
left a comment
There was a problem hiding this comment.
The noexcept must be removed from MetalDriver::execute in order for Metal driver exceptions to be caught.
6d2773e to
03038c2
Compare
z3moon
approved these changes
Apr 18, 2026
Contributor
z3moon
left a comment
There was a problem hiding this comment.
LGTM except for minor issues.
03038c2 to
9b04bbc
Compare
- Replaced assert_invariant with FILAMENT_CHECK_PRECONDITION in Renderer::beginFrame for caller bugs. - Removed noexcept from Camera::setCustomProjection to allow precondition checks to throw. - Removed noexcept from Texture and InstanceBuffer methods using precondition checks. - Documented silent clamping in View::setBloomOptions. - Clarified comment in FrameGraphResources regarding preconditions. - Refined MaterialInstance::commit to split texture loop into check and update passes, preventing partial state changes on precondition failure.
Introduce a mechanism to catch exceptions thrown on the backend thread and rethrow them on the main thread. This prevents deadlocks and allows the application to handle fatal backend failures gracefully. - Consolidate synchronization primitives in DriverBase. - Add mHasUnrecoverableError flag to interrupt blocked fence waits. - Optimize waitForFence to avoid extra atomic reads in common paths. - Propagate FenceStatus::ERROR across all backends. - CommandBufferQueue now stores a std::exception_ptr when the backend fails. - The backend enters a "zombie" state on failure, skipping further command execution but allowing clean shutdown. - Public APIs in Renderer and Engine now check for stored exceptions and rethrow them, documented with @throws. - Guarded by __EXCEPTIONS to ensure no overhead when exceptions are disabled. - Add unit test for fence interruption and document new APIs. BUGS=[407545700]
- Update Renderer::beginFrame() and Renderer::shouldRenderFrame() to return false early if an unrecoverable backend exception has been delivered to the main thread. - Document the new return behavior for beginFrame() and shouldRenderFrame() in Renderer.h. - Add Engine::hasUnrecoverableFailure() to the public API to allow apps to check for fatal errors without relying on exceptions. - Implement hasUnrecoverableFailure() in FEngine by delegating to CommandBufferQueue. - Expose Engine::hasUnrecoverableFailure() to Java bindings (Engine.java and JNI). - Expose Engine::hasUnrecoverableFailure() to JavaScript bindings (jsbindings.cpp).
9b04bbc to
5535913
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduce a mechanism to catch exceptions thrown on the backend thread and
rethrow them on the main thread. This prevents deadlocks and allows the
application to handle fatal backend failures gracefully.
BUGS=[407545700]
Fixes #8197, #3135