Repository: bevyengine/bevy
File: crates/bevy_render/src/lib.rs (Rust)

Code before:
                            "The TimeSender channel should always be empty during render. \
                            You might need to add the bevy::core::time_system to your app."
                        );
                    }
                    bevy_time::TrySendError::Disconnected(_) => {
                        // ignore disconnected errors, the main world probably just got dropped during shutdown
                    }
                }
            }
        })
        .add_systems(ExtractSchedule, PipelineCache::extract_shaders)
        .add_systems(
            Render,
            (
                // This set applies the commands from the extract schedule while the render schedule
                // is running in parallel with the main app.
                apply_extract_commands.in_set(RenderSystems::ExtractCommands),
                (PipelineCache::process_pipeline_queue_system, render_system)
                    .chain()
                    .in_set(RenderSystems::Render),
                despawn_temporary_render_entities.in_set(RenderSystems::PostCleanup),
            ),
        );

    render_app.set_extract(|main_world, render_world| {
        if error_handler::update_state(main_world, render_world) {
            // Run the `RenderStartup` if it hasn't run yet. This does mean `RenderStartup` blocks
            // the rest of the app extraction, but this is necessary since extraction itself can
            // depend on resources initialized in `RenderStartup`.
            render_world.run_schedule(RenderStartup);
        }

        {
            #[cfg(feature = "trace")]
            let _stage_span = bevy_log::info_span!("entity_sync").entered();
            entity_sync_system(main_world, render_world);
        }

        // run extract schedule
        extract(main_world, render_world);
    });

    let (sender, receiver) = bevy_time::create_time_channels();
    render_app.insert_resource(sender);
    app.insert_resource(receiver);
    app.insert_sub_app(RenderApp, render_app);
}

/// Applies the commands from the extract schedule. This happens during
/// the render schedule rather than during extraction to allow the commands to run in parallel with the
/// main app when pipelined rendering is enabled.

Review comment (suggestion):
The naming of `update_state` makes it quite hard to understand what this method call is doing. I would prefer a rename, but would accept a comment.

Code after:
            if let Err(error) = time_sender.0.try_send(Instant::now()) {
                match error {
                    bevy_time::TrySendError::Full(_) => {
                        panic!(
                            "The TimeSender channel should always be empty during render. \
                            You might need to add the bevy::core::time_system to your app."
                        );
                    }
                    bevy_time::TrySendError::Disconnected(_) => {
                        // ignore disconnected errors, the main world probably just got dropped during shutdown
                    }
                }
            }
        })
        .add_systems(ExtractSchedule, PipelineCache::extract_shaders)
        .add_systems(
            Render,
            (
                // This set applies the commands from the extract schedule while the render schedule
                // is running in parallel with the main app.
                apply_extract_commands.in_set(RenderSystems::ExtractCommands),
                (PipelineCache::process_pipeline_queue_system, render_system)
                    .chain()
                    .in_set(RenderSystems::Render),
                despawn_temporary_render_entities.in_set(RenderSystems::PostCleanup),
            ),
        );

    render_app.set_extract(|main_world, render_world| {
        error_handler::update_state(main_world, render_world);

        {
            #[cfg(feature = "trace")]
            let _stage_span = bevy_log::info_span!("entity_sync").entered();
            entity_sync_system(main_world, render_world);
        }

        // run extract schedule
        extract(main_world, render_world);
    });

    let (sender, receiver) = bevy_time::create_time_channels();
    render_app.insert_resource(sender);
    app.insert_resource(receiver);
    app.insert_sub_app(RenderApp, render_app);
}

/// Applies the commands from the extract schedule. This happens during
/// the render schedule rather than during extraction to allow the commands to run in parallel with the
/// main app when pipelined rendering is enabled.
fn apply_extract_commands(render_world: &mut World) {