intendednull / yewdux

Ergonomic state management for Yew applications
https://intendednull.github.io/yewdux/
Apache License 2.0
322 stars 31 forks source link

Is there any memory limitation? #38

Closed Raduc4 closed 1 year ago

Raduc4 commented 2 years ago

Hi, I'm using yewdux for a simple app to persist the local state, I'm uploading images into the state but when I refresh only 4 of them remain persistent, 1.5MB in total. Is there any method to increase it or to solve the problem?

intendednull commented 2 years ago

There is a persistence limit, but I doubt that's what's causing the problem at only a couple mb.

Can you share your code, or a minimal reproduction of the issue?

Raduc4 commented 2 years ago

https://github.com/Raduc4/evaluation-digitalization The main logic is into src/pages/home.rs Run the app: npm start

Raduc4 commented 2 years ago

/home/r/.cargo/registry/src/github.com-1ecc6299db9ec823/yewdux-0.8.2/src/storage.rs:74 Error saving state to storage: WebSys(JsValue(QuotaExceededError: The quota has been exceeded.
__wbg_set_0a2938f1ef0852cf/<@webpack://eval-digit/./pkg/index_bg.js?:896:55
handleError@webpack://eval-digit/./pkg/index_bg.js?:426:18
__wbg_set_0a2938f1ef0852cf@webpack://eval-digit/./pkg/index_bg.js?:895:48
__wbg_set_0a2938f1ef0852cf@http://localhost:8000/index.js:1887:48
web_sys::features::gen_Storage::Storage::set::ha6503e662279781c@http://localhost:8000/pkg.wasm:wasm-function[1160]:0x11e0bd
yewdux::storage::save::hb6ef574b3833d302@http://localhost:8000/pkg.wasm:wasm-function[256]:0x8d266
<yewdux::storage::StorageListener<T> as yewdux::listener::Listener>::on_change::h72d61cfd8187be20@http://localhost:8000/pkg.wasm:wasm-function[372]:0xac679
yewdux::listener::init_listener::{{closure}}::heb82fe5cfe8a8d3f@http://localhost:8000/pkg.wasm:wasm-function[4299]:0x1d50ee
<F as yewdux::subscriber::Callable<S>>::call::hd082d2c0d4c43b60@http://localhost:8000/pkg.wasm:wasm-function[9439]:0x25a79f
yewdux::subscriber::<impl yewdux::mrc::Mrc<yewdux::subscriber::Subscribers<S>>>::notify::h53dd1c9931ab9d88@http://localhost:8000/pkg.wasm:wasm-function[434]:0xb9eac
yewdux::dispatch::notify_subscribers::h8851e28fdeaa078a@http://localhost:8000/pkg.wasm:wasm-function[2340]:0x176daf
yewdux::dispatch::reduce::h65a9212b39fb7845@http://localhost:8000/pkg.wasm:wasm-function[815]:0xf84fe
yewdux::dispatch::reduce_mut::h6611e172e735c2a5@http://localhost:8000/pkg.wasm:wasm-function[2369]:0x178954
yewdux::dispatch::Dispatch<S>::reduce_mut::h4f2a62541a7d219f@http://localhost:8000/pkg.wasm:wasm-function[2049]:0x16417e
<yewchat::pages::home::Home as yew::html::component::Component>::update::h9573f848a2c6e385@http://localhost:8000/pkg.wasm:wasm-function[262]:0x8ee9c
<yew::html::component::lifecycle::UpdateRunner<COMP> as yew::scheduler::Runnable>::run::h46ebc20692222fd9@http://localhost:8000/pkg.wasm:wasm-function[137]:0x57fe8
yew::scheduler::start::{{closure}}::hcc77d74c7bd3d72f@http://localhost:8000/pkg.wasm:wasm-function[421]:0xb7531
std::thread::local::LocalKey<T>::try_with::he0651c201fff21c4@http://localhost:8000/pkg.wasm:wasm-function[2472]:0x17e983
std::thread::local::LocalKey<T>::with::hda1916db22cb981c@http://localhost:8000/pkg.wasm:wasm-function[6970]:0x225ebc
yew::scheduler::start::h22668e54b4ea774d@http://localhost:8000/pkg.wasm:wasm-function[15447]:0x2aa005
yew::html::component::scope::Scope<COMP>::push_update::h5d3690f43eec6cf7@http://localhost:8000/pkg.wasm:wasm-function[830]:0xfa22e
yew::html::component::scope::Scope<COMP>::send_message::h59f12179bfa04ef6@http://localhost:8000/pkg.wasm:wasm-function[874]:0xff6b9
<yewchat::components::input_image_component::FileInput as yew::html::component::Component>::update::{{closure}}::h4ab7835e113102b1@http://localhost:8000/pkg.wasm:wasm-function[664]:0xe31fd
gloo_file::file_reader::callbacks::read_as_bytes::{{closure}}::hb3a53634acf4866d@http://localhost:8000/pkg.wasm:wasm-function[896]:0x101fe8
gloo_file::file_reader::callbacks::read::{{closure}}::ha22ce6571dd805fc@http://localhost:8000/pkg.wasm:wasm-function[600]:0xd8d2d
<dyn core::ops::function::FnMut<(&A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h2562ba8e3e654606@http://localhost:8000/pkg.wasm:wasm-function[2278]:0x1732c1
__wbg_adapter_31@webpack://eval-digit/./pkg/index_bg.js?:402:53
real@webpack://eval-digit/./pkg/index_bg.js?:376:20
)) 8 [index_bg.js:807:13](webpack://eval-digit/./pkg/index_bg.js?)
    __wbg_error_00c5d571f754f629 webpack://eval-digit/./pkg/index_bg.js?:807
    logError webpack://eval-digit/./pkg/index_bg.js?:347
    __wbg_error_00c5d571f754f629 webpack://eval-digit/./pkg/index_bg.js?:806
    __wbg_error_00c5d571f754f629 http://localhost:8000/index.js:1819
    hca209c4b59e7f5ce http://localhost:8000/pkg.wasm:2069931
    <wasm_logger::WasmLogger as log::Log>::log::he0076a82e866b470 http://localhost:8000/pkg.wasm:454138
    h2e79b6a4d13ce5f1 http://localhost:8000/pkg.wasm:943988
    <yewdux::storage::StorageListener<T> as yewdux::listener::Listener>::on_change::h72d61cfd8187be20 http://localhost:8000/pkg.wasm:706759
    heb82fe5cfe8a8d3f http://localhost:8000/pkg.wasm:1921262
    <F as yewdux::subscriber::Callable<S>>::call::hd082d2c0d4c43b60 http://localhost:8000/pkg.wasm:2467743
    yewdux::subscriber::<impl yewdux::mrc::Mrc<yewdux::subscriber::Subscribers<S>>>::notify::h53dd1c9931ab9d88 http://localhost:8000/pkg.wasm:761516
    h8851e28fdeaa078a http://localhost:8000/pkg.wasm:1535407
    h65a9212b39fb7845 http://localhost:8000/pkg.wasm:1017086
    h6611e172e735c2a5 http://localhost:8000/pkg.wasm:1542484
    h4f2a62541a7d219f http://localhost:8000/pkg.wasm:1458558
    <yewchat::pages::home::Home as yew::html::component::Component>::update::h9573f848a2c6e385 http://localhost:8000/pkg.wasm:585372
    <yew::html::component::lifecycle::UpdateRunner<COMP> as yew::scheduler::Runnable>::run::h46ebc20692222fd9 http://localhost:8000/pkg.wasm:360424
    hcc77d74c7bd3d72f http://localhost:8000/pkg.wasm:750897
    he0651c201fff21c4 http://localhost:8000/pkg.wasm:1567107
    hda1916db22cb981c http://localhost:8000/pkg.wasm:2252476
    h22668e54b4ea774d http://localhost:8000/pkg.wasm:2793477
    h5d3690f43eec6cf7 http://localhost:8000/pkg.wasm:1024558
    h59f12179bfa04ef6 http://localhost:8000/pkg.wasm:1046201
    <yewchat::components::input_image_component::FileInput as yew::html::component::Component>::update::{{closure}}::h4ab7835e113102b1 http://localhost:8000/pkg.wasm:930301
    hb3a53634acf4866d http://localhost:8000/pkg.wasm:1056744
    ha22ce6571dd805fc http://localhost:8000/pkg.wasm:888109
    <dyn core::ops::function::FnMut<(&A,)>+Output = R as wasm_bindgen::closure::WasmClosure>::describe::invoke::h2562ba8e3e654606 http://localhost:8000/pkg.wasm:1520321
    __wbg_adapter_31 webpack://eval-digit/./pkg/index_bg.js?:402
    real webpack://eval-digit/./pkg/index_bg.js?:376

​```
intendednull commented 2 years ago

Error saving state to storage: WebSys(JsValue(QuotaExceededError: The quota has been exceeded.

Looks like that is the problem! You can increase your quota, but this is not ideal seeing as each user would need to do this manually. Also this post may have some insight.

Seems like IndexDB is your best bet here. Should be fairly trivial to get it working with Yewdux. I would also be open to adding official support sometime soon.

intendednull commented 1 year ago

This isn't really solvable through Yewdux, so closing for now