bevy/release-content/migration-guides/extract_fn_is_mut.md
andriyDev 2c6cf9a597
Run RenderStartup in/before extract instead of after it. (#19926)
# Objective

- Fixes #19910.

## Solution

- First, allow extraction function to be FnMut instead of Fn. FnMut is a
superset of Fn anyway, and we only ever call this function once at a
time (we would never call this in parallel for different pairs of worlds
or something).
- Run the `RenderStartup` schedule in the extract function with a flag
to only do it once.
- Remove all the `MainRender` stuff.

One sad part here is that now the `RenderStartup` blocks extraction. So
for pipelined rendering, our simulation will be blocked on the first
frame while we set up all the rendering resources. I don't see this as a
big loss though since A) that is fundamentally what we want here -
extraction **has to** run after `RenderStartup`, and the only way to do
better is to somehow run `RenderStartup` in parallel with the first
simulation frame, and B) without `RenderStartup` the **entire** app was
blocked on initializing render resources during Plugin construction - so
we're not really losing anything here.

## Testing

- I ran the `custom_post_processing` example (which was ported to use
`RenderStartup` in #19886) and it still works.
2025-07-07 01:31:40 +00:00

11 lines
365 B
Markdown

---
title: `take_extract` now returns `dyn FnMut` instead of `dyn Fn`.
pull_requests: [19926]
---
Previously, `set_extract` accepted any `Fn`. Now we accept any `FnMut`. For callers of
`set_extract`, there is no difference since `Fn: FnMut`.
However, callers of `take_extract` will now be returned
`Option<Box<dyn FnMut(&mut World, &mut World) + Send>>` instead.