Skip to content

on 0.19.0 web firefox, demo loading screen, pipelines no longer become ready #24944

Description

@djkato

Bevy version and features

bevy = { version = "0.19.0" }

[Optional] Relevant system information

cargo 1.95.0 (f2d3ce0bd 2026-03-21)
Zen 1.21.5b (Firefox 152.0.4) (64-bit)
RX 7900 XT GPU
App compiled for Wasm with wasm-pack build --release --target web, wasm-pack 0.15.0

What you did

first discussed here: https://discord.com/channels/691052431525675048/1525161866735779840
During migration from 0.18.1 to 0.19.0, my loading states inspired by the Loading screen example were no longer updating. This part of the code worked fine since I first wrote it in 0.16.x. Tracked this down to this function never actually saying pipelines were ready, even tho the scene was rendering fine already:

update_pipelines_ready start threed.js:1309:21
Some pipelines: 1
^ gets repeated in the console indefnitely

fn update_pipelines_ready(mut main_world: ResMut<MainWorld>, pipelines: Res<PipelineCache>) {
    console_log("update_pipelines_ready start");
    if let Some(mut pipelines_ready) = main_world.get_resource_mut::<PipelinesReady>() {
        console_log(&format!(
            "Some pipelines: {}",
            pipelines.waiting_pipelines().count()
        ));
        pipelines_ready.0 = pipelines.waiting_pipelines().count() == 0;
    }
}

What went wrong

LoadingState never switched to Ready, cause pipelines were never done.

Additional information

Entire loading snippet:

pub struct LoadingStateTracker;

impl Plugin for LoadingStateTracker {
    fn build(&self, app: &mut App) {
        app.insert_resource(PipelinesReady::default())
            .insert_resource(LoadingData::new(5))
            .insert_resource(LoadingState::default())
            .add_systems(Update, update_loading_data);

        app.sub_app_mut(bevy::render::RenderApp)
            .add_systems(ExtractSchedule, update_pipelines_ready);
    }
}

#[derive(Resource, Debug, Default)]
struct PipelinesReady(pub bool);

#[derive(Resource, Default, Debug, PartialEq)]
pub enum LoadingState {
    Ready,
    #[default]
    Loading,
}
#[derive(Resource, Debug, Default)]
struct LoadingData {
    loading_assets: Vec<UntypedHandle>,
    confirmation_frames_target: usize,
    confirmation_frames_count: usize,
}

impl LoadingData {
    fn new(confirmation_frames_target: usize) -> Self {
        Self {
            loading_assets: Vec::new(),
            confirmation_frames_target,
            confirmation_frames_count: 0,
        }
    }
}
fn update_pipelines_ready(mut main_world: ResMut<MainWorld>, pipelines: Res<PipelineCache>) {
    if let Some(mut pipelines_ready) = main_world.get_resource_mut::<PipelinesReady>() {
        pipelines_ready.0 = pipelines.waiting_pipelines().count() == 0;
    }
}

fn update_loading_data(
    mut loading_data: ResMut<LoadingData>,
    mut loading_state: ResMut<LoadingState>,
    asset_server: Res<AssetServer>,
    pipelines_ready: Res<PipelinesReady>,
) {
    console_log(&format!(
        " if !{} || !{}",
        loading_data.loading_assets.is_empty(),
        pipelines_ready.0
    ));
    if !loading_data.loading_assets.is_empty() || !pipelines_ready.0 {
        console_log("still loading...");
        loading_data.confirmation_frames_count = 0;
        loading_data.loading_assets.retain(|asset| {
            asset_server
                .get_recursive_dependency_load_state(asset)
                .is_none_or(|state| !state.is_loaded())
        });
    } else {
        loading_data.confirmation_frames_count += 1;
        if loading_data.confirmation_frames_count == loading_data.confirmation_frames_target {
            *loading_state = LoadingState::Ready;
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-BugAn unexpected or incorrect behaviorO-WebGL2Specific to the WebGL2 render APIP-RegressionFunctionality that used to work but no longer does. Add a test for this!S-Needs-InvestigationThis issue requires detective work to figure out what's going wrong

    Type

    No type

    Projects

    Status
    Needs SME Triage

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions