fix(web): clamp wgpu surface to CSS pixels on HiDPI to prevent wasm panic
Build and Deploy / build-and-push (push) Successful in 4m52s
Web E2E / web-e2e (push) Successful in 4m12s

Root cause: fit_canvas_to_parent requests a wgpu surface sized in
physical pixels (CSS pixels × devicePixelRatio). On HiDPI displays
(DPR ≈ 2) the physical size (e.g. 2612×1469) exceeds WebGL2's per-
dimension texture limit of 2048, triggering a wgpu validation panic
that kills the WASM thread immediately on the first window resize.

Fix: add `resolution: WindowResolution::default().with_scale_factor_override(1.0)`
to the primary window so Bevy uses CSS/logical pixels as the surface
dimensions. For a 1306×734 CSS viewport this keeps the framebuffer well
within 2048 regardless of devicePixelRatio.

Also remove the temporary [drag] console logging added in the previous
commit — the panic was causing drag to never run, not a hit-test bug.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
funman300
2026-06-02 13:28:25 -07:00
parent 8b736cae3c
commit 8b262afcd2
4 changed files with 22 additions and 34 deletions
+1 -21
View File
@@ -621,35 +621,15 @@ fn start_drag(
{
return;
}
let Some(layout) = layout else {
bevy::log::warn!("[drag] no layout — skipping");
return;
};
let Some(layout) = layout else { return };
let Some(world) = cursor_world(&windows, &cameras) else {
bevy::log::warn!("[drag] cursor_world returned None (no camera?)");
return;
};
// Don't pick up the stock — that is handled by handle_stock_click.
let Some((pile, stack_index, card_ids)) = find_draggable_at(world, &game.0, &layout.0) else {
bevy::log::info!(
"[drag] no draggable at world {:?} — stock={:?} waste_len={} tab_lens={:?}",
world,
layout.0.pile_positions.get(&KlondikePile::Stock),
game.0.waste_cards().len(),
[
game.0.pile(KlondikePile::Tableau(Tableau::Tableau1)).len(),
game.0.pile(KlondikePile::Tableau(Tableau::Tableau2)).len(),
game.0.pile(KlondikePile::Tableau(Tableau::Tableau3)).len(),
game.0.pile(KlondikePile::Tableau(Tableau::Tableau4)).len(),
game.0.pile(KlondikePile::Tableau(Tableau::Tableau5)).len(),
game.0.pile(KlondikePile::Tableau(Tableau::Tableau6)).len(),
game.0.pile(KlondikePile::Tableau(Tableau::Tableau7)).len(),
]
);
return;
};
bevy::log::info!("[drag] started: pile={:?} stack_index={} cards={:?}", pile, stack_index, card_ids);
let bottom_pos = card_position(&game.0, &layout.0, &pile, stack_index);