-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Enable SharedArrayBuffer for apps #605
Comments
Thanks again. Looking into this ✌️ |
One of the instructions on that article says this:
Puter relies heavily on |
I made a quick POC, you can try running on your side: https://domain-a/main.html served with
<iframe src="https://domain-b/iframe.html" allow="cross-origin-isolated"></iframe>
<script>
console.log(`main has SharedArrayBuffer ${window.SharedArrayBuffer ? "TRUE" : "FALSE"}`)
const iframe = document.querySelector("iframe");
setInterval(() => iframe.contentWindow.postMessage("hello from main", "*"), 1000)
onmessage = event => console.log("main.onmessage", event.data);
</script> https://domain-b/iframe.html served with:
<script>
console.log(`iframe has SharedArrayBuffer ${window.SharedArrayBuffer ? "TRUE" : "FALSE"}`)
setInterval(() => parent.postMessage("hello from iframe", "*"), 1000);
onmessage = event => console.log("iframe.onmessage", event.data);
</script> now open https://domain-a/main.html in browser and console prints:
tested in chrome and firefox |
I've added a config option for self-hosted installations. This will allow us to do further testing within Puter and make sure everything still works. In the meantime you can test your app in this environment to ensure SharedArrayBuffer works now. |
Thanks for looking into it. As I am not running self-hosted installation, I will wait until this lands on puter.com. Please keep this thread updated... I would like to add 2 mighty apps 💪 . |
If we add these headers on |
To my knowledge, if the top window (puter.com) is not isolated (doesnt have SharedArrayBuffer) the iframes loaded within it will not be isolated (no SAB) either no matter what headers are sent with these iframes ( https://stackoverflow.com/questions/69322834/is-it-possible-to-embed-a-cross-origin-isolated-iframe-inside-a-normal-page ). I can confirm this following my own testing. |
We have some more ideas. Adding cross-origin isolation breaks a lot of Puter apps hosted on 3rd party sites. What I think we're going to have to do is allow the user to enter a mode where the headers are sent by |
Are you considering the whole puter.com being isolated, but by default the app iframes will be not? And so author of the app will have a chckbox to change this mode for a particular app/iframe? |
Isolating |
I see, Thats not optimal. Having an app in a new tab/window feels like I could open the app url directly without puter being involved at all, What is it that breaks within other 3rd party apps? If I know a little more I might be helpful to resolve |
As I understand it, when we add these headers on
any app from a third-party origin ( |
once puter.com sends the example-app.com can be loaded in iframe when:
On top of that for example-app.com to have access to SAB So until safari and firefox delivers the needed
This has been problematic since the whole COOP/COEP was invented, esp common case is embedding youtube videos to isolated sites (SO) Related POC: |
Thanks for looking into that! We can definitely add the attributes that make this work in chromium and hope that other browsers add support later. I don't know if we'd want to go so far as encouraging users to drop Blink competitors - I actually think we need more browser diversity (the Ladybird project for example is trying to accomplish this), but I think we can detect a chromium UA string and enable cross-origin-isolation for that case, showing a "this only works in chromium" message on apps requiring this feature. |
I think we got it! Give it a try, we've already deployed the changes to |
@jozefchutka our fix is live on puter.com. I tested |
I can cofirm having SAB available in my app. Thank you for fast iteration and delivery. Great job. (feel free to close this issue, seems resolved to me) |
Awesome to hear! 🎉 |
As discussed on https://discord.com/channels/1071986474041495705/1224431787808129138/1263169223274791036 , I would like to request SharedArrayBuffer (cross origin isolation) for apps.
Here is a good article describing the importance and how to enable it https://web.dev/articles/cross-origin-isolation-guide
The text was updated successfully, but these errors were encountered: