Closed Blame4 closed 3 years ago
Hello
Option 1 and 4 are the only options that work out of the box. I'm not sure what api you are referring to in option 2, but iirc not available for web workers.
I might give a shot at getting indexDb working, as some other people have requested it. However creating an implementation of IJSRuntime compatible with the Blazor implementation is not trivial.
That said, i have been working a lot with big file upload in Blazor, and I've never had any issues with the ui freezing up. Did you implement the upload yourself or did you use a component? Did you try the Tewr.Blazor.FileReader project ?(https://github.com/Tewr/BlazorFileReader)
Edit: after reading again, your option 4 contains a lot of different thoughts, I'm not sure any of it is trivial. As this component is built today, all communication is done with strings in postmessage.
Thank you for replying. I will try your filereader. BlazorWorker is a great project, and update very quick. I'm new to Web App, and Choosing the WASM for a low server managment reason, sometimes need to work offline . I used to use the native InputFile Component.Then use HttpClient putasync the stream. Whether cached the file in the wasm virtural file system or not, it stuck after the customized SerializeToStreamAsync function return. Yes, I used the HttpProgress nutget to get the upload progress. Usually it blocked the UI when approaching 99%. The performance profile shows that the fetch function blocked the thread for senconds if file is larger than 50M.
Hello
Option 1 and 4 are the only options that work out of the box. I'm not sure what api you are referring to in option 2, but iirc not available for web workers.
I might give a shot at getting indexDb working, as some other people have requested it. However creating an implementation of IJSRuntime compatible with the Blazor implementation is not trivial.
That said, i have been working a lot with big file upload in Blazor, and I've never had any issues with the ui freezing up. Did you implement the upload yourself or did you use a component? Did you try the Tewr.Blazor.FileReader project ?(https://github.com/Tewr/BlazorFileReader)
Edit: after reading again, your option 4 contains a lot of different thoughts, I'm not sure any of it is trivial. As this component is built today, all communication is done with strings in postmessage.
Indexed db support would honestly be great! I tried a main thread controller pattern and got it working to store to the dB but unfortunately due to the amount of db calls I need between the border the overall process is much slower than having it all on the main thread making the web worker redundant in my use case.
I wonder if you could get in touch with Microsoft somehow so they could help support this library. Its a pretty significant blazor library.
I saw your filereader demo. I think my problem is the httpclient.putasync method. I never cache the file in memory,which I can do without any problem. I think I need a real putasync method, or leave the blocking task in web worker.
I'm closing this due to lack of activity
I wonder if I can share data with worker process. Option 1: Use raw json serialized string, too frequent postmessage Option2: Use browser storage, avaliable, but not for big object Option3: Use indexDB, with nutget, and JSRuntime injection support Option4: Use distribute cache service, like redis, ncache, but I prefer build-in memory distribute cache, but in that case, worker need an access to registered service in app instance, or just the instance can be pass to worker(not sure how distribure memory cache instance be managed).Mainly I'm working on WASM. The server does not need to access the processing data.
It's faster if I can use memory cache to buffer the file stream in bucks queque, the worker read the stream bucks and upload asynchronously
Any way, the final goal is to use web worker asynchronously upload large file to outside web api.I can do that within the app process use async hronous function without blocking the UI, until the the fetch function invkoed. I inspected the browser performance profile, the fetch function blocked ui, and I can do nothing about it.Httpclient async function use fetch internally, not really async in WASM.