fix(web): clamp wgpu surface to CSS pixels on HiDPI to prevent wasm panic
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:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user