-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running spl.js in a shared worker #18
Comments
Hello @duvifn, I think I have tried to disable almost everything that is related to threading/concurrency to avoid any headaches for the compilation. And I am afraid I am not up-to-date with all the developments in emscripten etc to support threads and so forth. I am not sure if in your use case having a SharedWorker necessarily involves a shared db connection? I think a starting point could be to look into SQLite's own WebAssembly port or SQL.js to see if it is possible in SQLite. If so then it may well be possible with SpatiaLite. |
Hi, thanks for your reply. Hope I correctly understood you. |
For my use case it's fine that there would be only one connection per db. |
I have to confess I am not familiar with the SharedWorker API. So if all reads/writes are sequential then from the point of view of the db worker it should not be a big difference. Did you try to just replace Worker with a SharedWorker instance (I'd guess it requires a few adjustments). If you would create a test branch I could maybe help you a bit. |
Thanks. Note that by default Another limitation is that currently, extensions should be defined on worker creation only, and can't be updated after that (I didn't want to change current code model, but it could be changed relatively easily). Thank you very much! |
Thanks for sharing the code @duvifn. Please give me a bit of time to read it and go through the |
Hi @duvifn, I read the SharedWorker documentation and looked at a few examples. My first impression was that this quite interesting and should not be too difficult to just replace the dedicated Worker with the SharedWorker (maybe supported by an optional setting like |
@jvail Thanks for reviewing this. The spec says:
So if the worker I have tried this with pages of the same origin and it works. |
Thank you @duvifn,
I gave it a try with a simple example and indeed with a data uri it seems to work although on stack overflow someone complained it would set the secure context to false... It seems it's not the case. This is all very interesting but a bit hard to digest. But the reason may well be that I have not read my own code for quite some time ;) However a few questions:
|
Can you share a link? I'm not sure what does this mean in the context of a SharedWorker.
No. This means that every browsing context (windows, iframes, workers, etc...) has its own set of database connections. Different browsing context can access any db managed by this worker, according to the default behavior of
No. Every
A very simple example (put the two files on a server, and import File1
|
https://stackoverflow.com/questions/73098559/data-url-web-worker-loses-security-context
Ok, I need to play a bit with your example. I thought we could maybe make all databases available to all tabs/contexts without actually knowing the path.
Thank you. I'll continue from there. I always need examples to make up my mind. |
Hi @duvifn, apologies for the late reply: I think this is a very interesting feature and thank you for sharing your code. But I came to the conclusion that I would like to wait a little bit for various reasons:
P.S.: Forgot to mention that as part of the little refactoring I could also split the single file into client, worker and wasm file. I'd guess this would also make implementing a SharedWoker abit easier. If you have other ideas then let me know. |
@jvail thanks.
I respect that.
In my implementation multiple writes should work with implicit transactions because JS event driven architecture guarantees that only one transaction happens at a given time.
I continue to push commits with improvements as I need (as you can see in my branch). I actually use this branch so any issue is fixed in this branch. |
Salut @duvifn, not sure if you are still interested in working on the sharedworker idea... However, I have finally managed to put together a release so I can start thinking about the next ideas towards a version 1.0:
Let me know what the status of your project is and if you are still working on it. Unfortunately I can not promise to move on much quicker... it will all take time. |
Closing for now ... |
Hello @jvail,
This is a feature request.
I have a use case where it would be useful to access a db from a different iframe/window.
Is it possible to make
spl.js
running from aSharedWorker
rather than a dedicated worker?Thank you very much!
The text was updated successfully, but these errors were encountered: