[whatwg/encoding] Throw exception when text encode alloc memory fail. (Issue #334)

### What is the issue with the Encoding Standard?

In Edge and Chrome, we have found that TextEncoder [Encoding Standard (whatwg.org)](https://encoding.spec.whatwg.org/) may encounter OOM (Out of Memory) errors when encode text, not only due to large memory allocation but also for some unknown reasons. 
Our current strategy is to crash the renderer process. We now want to optimize this behavior by throwing an exception when memory allocation fails.

I tested encode with a long string in Firefox and Safari browsers.
Firefox will throw a exception "out of memory".
<img width="612" alt="image" src="https://github.com/user-attachments/assets/da122fc6-f8d2-4966-ab5c-18b5587a1bf2">
Safari will return a empty UInt8Array.

I noticed that the current standards do not define how to handle OOM (Out of Memory) situations.Do we need to establish such a standard?




-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/encoding/issues/334
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/encoding/issues/334@github.com>

Received on Thursday, 8 August 2024 10:31:36 UTC