Skip to content
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

structuredClone into (Shared) ArrayBuffer #10468

Closed
WebReflection opened this issue Jul 10, 2024 · 7 comments
Closed

structuredClone into (Shared) ArrayBuffer #10468

WebReflection opened this issue Jul 10, 2024 · 7 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest

Comments

@WebReflection
Copy link
Contributor

WebReflection commented Jul 10, 2024

What problem are you trying to solve?

I am the maintainer of the polyfill that has 77+ Million downloads per months and most of those "millions" are around the @ungap/structured-clone/json functionality, because this standard doesn't allow to:

  • create intermediate state after parsing operation (that is stringify or any other byte-ify operation)
  • allow parsing of the intermediate representation of the data that passes through postMessage dance

The idea here is that it's OK to not specify a string representation of the algorithm that's involved, but at least it would be sensible, lovely, useful, to allow such algorithm to work with ArrayBuffer or, even better, SharedArrayBuffer.

The fact I need to make a string out of my polyfill feature, to then fill a buffer with such UTF-16 string, and parse it once received on the other end makes literally no sense to me ... if I could just have a structuredClone.toBuffer and a structuredClone.fromBuffer everything would be smoother and better for a plethora of projects using Workers behind the scene to communicate omplex data to the Main thread, and vice-versa.

What solutions exist today?

One needs to use my polyfill to make sense of structuredClone algorithm, and yet tat polyfill can't survive some special case that native algorithm supports.

How would you solve it?

I would add a structuredCloneView(source) that returns a view of that buffer and structuredCloneFrom(bufferOrTypedArray) that returns cloned data on the receiver.

Alternatively, I would add primitives to clone into a buffer, but knowing the desired buffer length AOT (Ahead Of Time) might be tricky, so that previous hints could solve all the issues already.

Anything else?

This API is both wonderful and too hidden behind "core-developers" scene, where it could shine and enable the unthinkable as long as it is usable beside postMessage dance.

@WebReflection WebReflection added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Jul 10, 2024
@annevk
Copy link
Member

annevk commented Jul 10, 2024

This is a duplicate of #3517.

@annevk annevk closed this as not planned Won't fix, can't repro, duplicate, stale Jul 10, 2024
@WebReflection
Copy link
Contributor Author

Related issue at TC39 level for history sake: https://es.discourse.group/t/atomics-waituntil/2083

@WebReflection
Copy link
Contributor Author

WebReflection commented Jul 10, 2024

@annevk opened in 2018 and stuck until 2021 (it's 2024 now) ... how is this handling users' requests going?

@annevk
Copy link
Member

annevk commented Jul 10, 2024

There are a great many problems to tackle as you can see from the issue tracker and very few people to go around. If you want to see something happen your best bet is investing the time to make it so.

@WebReflection
Copy link
Contributor Author

WebReflection commented Jul 10, 2024

I see ... your suggestion is that I create at least 3 PRs to WebKit, Chromium, and Firefox code bases, around an issue stuck in time since 2018 ... sounds reasonable, if I did work for Igalia and there was sponsored interest around it ... 🤷‍♂️

@annevk
Copy link
Member

annevk commented Jul 10, 2024

At some point you might want to reflect on why your engagement with standards bodies does not seem to be fruitful.

@WebReflection
Copy link
Contributor Author

@annevk I didn't mean to offend anyone but your message was a bit over my capabilities ... I do work full time already and with a 2yo around there's little extra time for anything else. If I could contribute directly I would but I don't know those code bases inside out like many of you here, or in Igalia, do so ... you basically gently reminded me that's never going to happen and it's a sad resolution to me but surely it's mostly my fault.

Anyway, thanks for the pointer, I hope one day that will be closed as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest
Development

No branches or pull requests

2 participants