fix: stabilize web loading and paper rendering

This commit is contained in:
Hakan Seven committed 2026-07-25 21:34:29 +03:00
1 parent fe49cc8eb5
commit bca65600cd
25 files changed
+109 -62

No files matched your search

+2
View File
@@ -228,6 +228,7 @@ pub(super) struct DocumentTab {
pub(super) last_synced_camera_gen: u64,
/// Render-state key of `scene.document.preview`. Matching saves reuse the
/// encoded DWG thumbnail instead of rescanning every resident wire.
#[cfg(not(target_arch = "wasm32"))]
pub(super) thumbnail_cache_key: Option<super::ThumbnailCacheKey>,
/// Sentinel "Welcome / Start" tab. Always at index 0 when present.
/// Cannot be closed; the viewport area renders a welcome page instead
@@ -463,6 +464,7 @@ impl DocumentTab {
block_edit: None,
active_mleader_style: "Standard".to_string(),
last_synced_camera_gen: 0,
#[cfg(not(target_arch = "wasm32"))]
thumbnail_cache_key: None,
is_start: false,
pan_mode: false,
+9
View File
@@ -755,7 +755,9 @@ pub(super) struct OpenCADStudio {
pending_close: Option<PendingClose>,
/// Latest save job per stable tab id. Older completions may finish, but
/// cannot mark a newer document state clean or redirect its path.
#[cfg(not(target_arch = "wasm32"))]
active_save_jobs: std::collections::HashMap<u64, u64>,
#[cfg(not(target_arch = "wasm32"))]
save_job_serial: u64,
/// OS window for the unsaved-changes confirmation dialog.
@@ -866,6 +868,7 @@ pub(super) enum PendingClose {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg(not(target_arch = "wasm32"))]
pub(super) enum SavePurpose {
Manual,
SaveAs,
@@ -873,6 +876,7 @@ pub(super) enum SavePurpose {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg(not(target_arch = "wasm32"))]
pub(super) enum SaveContinuation {
None,
CloseTab,
@@ -880,6 +884,7 @@ pub(super) enum SaveContinuation {
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg(not(target_arch = "wasm32"))]
pub(super) struct ThumbnailCacheKey {
epoch: u64,
camera_generation: u64,
@@ -889,6 +894,7 @@ pub(super) struct ThumbnailCacheKey {
}
#[derive(Debug, Clone)]
#[cfg(not(target_arch = "wasm32"))]
pub struct SaveOutcome {
job_id: u64,
tab_id: u64,
@@ -1463,6 +1469,7 @@ pub enum Message {
/// Periodic autosave tick — write `.sv$` recovery files for dirty tabs.
AutoSave,
/// Native background save/autosave completed.
#[cfg(not(target_arch = "wasm32"))]
SaveFinished(SaveOutcome),
// ─────────────────────────────────────────────────────────────────────
CommandInput(String),
@@ -2505,7 +2512,9 @@ impl OpenCADStudio {
active_interaction_index: None,
queued_interaction_indices: std::collections::VecDeque::new(),
pending_close: None,
#[cfg(not(target_arch = "wasm32"))]
active_save_jobs: std::collections::HashMap::new(),
#[cfg(not(target_arch = "wasm32"))]
save_job_serial: 0,
save_dialog_format: "DWG 2018".to_string(),
save_dialog_filename: "drawing.dwg".to_string(),
+2 -2
View File
@@ -783,7 +783,7 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
)
})
};
let clone_started = std::time::Instant::now();
let clone_started = iced::time::Instant::now();
let mut snapshot = self.tabs[i].scene.document.clone();
let clone_ms = clone_started.elapsed().as_secs_f64() * 1000.0;
if crate::perf::enabled() {
@@ -807,7 +807,7 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
let (result, refreshed_preview) = std::thread::spawn(move || {
let mut refreshed_preview = None;
if let Some((wires, camera, bg_color, png, viewport)) = thumbnail {
let started = std::time::Instant::now();
let started = iced::time::Instant::now();
snapshot.preview = crate::io::thumbnail::from_snapshot(
&wires,
&camera,
-3
View File
@@ -3954,9 +3954,6 @@ impl OpenCADStudio {
#[cfg(not(target_arch = "wasm32"))]
Message::SaveFinished(outcome) => self.on_save_finished(outcome),
#[cfg(target_arch = "wasm32")]
Message::SaveFinished(_) => Task::none(),
// ── Page Setup ────────────────────────────────────────────────
Message::UpdateCheckResult(latest) => {
let Some(info) = latest else {
+1 -1
View File
@@ -3639,7 +3639,7 @@ impl OpenCADStudio {
let weak = Arc::downgrade(&wires);
Some(Task::perform(
async move {
let started = std::time::Instant::now();
let started = iced::time::Instant::now();
let index = Arc::new(
crate::scene::pick::interaction_index::InteractionIndex::build(&wires),
);