egui icon indicating copy to clipboard operation
egui copied to clipboard

Web App doesn't save state (but Native does)

Open robertpauson opened this issue 2 years ago • 2 comments

despite this:

    fn save(&mut self, storage: &mut dyn eframe::Storage) {
        eframe::set_value(storage, eframe::APP_KEY, self);
    }
    fn auto_save_interval(&self) -> std::time::Duration {
        std::time::Duration::from_secs(30)
    }

every time webpage opens, reset happens. persistence feature is enabled I've made the cache name in sw.js same as canvas id Moreover (but this may be server side issue?) if I update the app, I need to delete cookies and reload, it won't automatically load the latest version (acting as if it's offline?)

robertpauson avatar Dec 03 '22 03:12 robertpauson

could you double check if the native persistence is working? ive got a similar issues but native linux

fn save(&mut self, storage: &mut dyn eframe::Storage) {
    info!("saving data");
    storage.set_string(KEY_DEEPL_KEY, self.global.service.auth_key.clone());
    storage.flush();
}

if its not working, i would guess we using the wrong sets of feature flags or dont use it like it has to be used. currently using the latest: eframe = { version = "0.20.0", features = ["persistence"] }

if its working ill open an seperate issues to not conquer your report.

to make this report better i would suggest that you add your used version too.

Nebdir avatar Dec 08 '22 20:12 Nebdir

could you double check if the native persistence is working? ive got a similar issues but native linux

all my app versions successfully save state running on native (local PC). Sometimes it takes a moment on close, but that's okay. All those same versions fail to save state on web. I'll try newer versions soon and update here but 0.19.0 works as I described above.

I really wish this got fixed ASAP. Or if there is no bug, for Emil to create a tutorial to explain exactly what works and what won't.

robertpauson avatar Dec 19 '22 03:12 robertpauson

eframe auto-saves every 30 seconds. eframe native also saves on exit. I just added this to eframe:

  • https://github.com/emilk/egui/pull/2927

please try latest egui master and see if it now works for you. Otherwise, try adding some tracing::info log calls in the surrounding the eframe web save code (AppRunner::save in crates/eframe/src/web/backend.rs) and check the browser dev console and see if you can figure out what is going wrong

emilk avatar Apr 18 '23 18:04 emilk