Skip to content

Commit 112c574

Browse files
authored
Merge pull request #1 from maceip/address-pr-comments
Address pr comments
2 parents c93d8f6 + 24f5a63 commit 112c574

105 files changed

Lines changed: 1969 additions & 480 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"attribution": {
3+
"commit": "",
4+
"pr": ""
5+
}
6+
}

ChangeLog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ See docs/process.md for more on how version tagging works.
2424
API stub functions. These stub functions where never designed to work under
2525
Wasm Workers, so its safer to error at link time if pthread APIs are used
2626
in Wasm Worker-based programs. (#26336)
27+
- SDL2 port updated to include stub functions for `SDL_hid_init()` and related
28+
functions. (#26297)
2729

2830
5.0.2 - 02/25/26
2931
----------------
@@ -46,8 +48,6 @@ See docs/process.md for more on how version tagging works.
4648
C `bool` type rather than `int`. For example `emscripten_proxy_sync` and
4749
`emscripten_is_main_runtime_thread`. (#26316)
4850
- SDL2 port updated from 2.32.8 to 2.32.10. (#26298)
49-
- SDL2 port updated to include stub functions for `SDL_hid_init()` and related
50-
functions. (#26297)
5151
- The remaining launcher scripts (e.g. `emcc.bat`) were removed from the git
5252
repository. These scripts are created by the `./bootstrap` script which
5353
must be run before the toolchain is usable (for folks using a git checkout of

site/source/docs/compiling/Deploying-Pages.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ An inherent property of asm.js and WebAssembly applications is that they need a
7171

7272
Because this memory allocation needs to be contiguous, it can happen that the user's browser process does have enough memory, but only the address space of the process is too fragmented, and there is not enough linear address space available to satisfy the allocation. To avoid this issue, the best practice is to allocate the ``WebAssembly.Memory`` object (``ArrayBuffer`` for asm.js) up front at the top of the main page, before any other allocations or page script load actions are done. This ensures that the allocation has best chances to succeed. See the fields ``Module['buffer']`` and ``Module['wasmMemory']`` for more information.
7373

74-
Additionally, it is possible to opt in to content process isolation specifically for a web page that needs this kind of a large allocation. To utilize this machinery, specify the HTTP response header ``Large-Allocation: <MBytes>`` when serving the main html page. This support is currently implemented in Firefox 53.
75-
7674
Last, it is easy to accidentally cling to large unneeded blocks of memory after the page has loaded. For example, in WebAssembly, once the WebAssembly Module has been instantiated to a ``WebAssembly.Instance`` object, the original ``WebAssembly.Module`` object is no longer needed in memory, and it is best to clear all references to it so that the garbage collector can reclaim it, because the Module object can be dozens of megabytes in size. Similar, make sure that all XHRed files, asset data and large scripts are not referenced anymore when not used. Check out the browser's memory profiling tool, and the ``about:memory`` page in Firefox to perform memory profiling to ensure that memory is not being wasted.
7775

7876
Robust Error Handling
@@ -106,7 +104,7 @@ This way the page will be future compatible once support for the particular feat
106104

107105
- Use a network limiter tool to constrain download or upload bandwidth speeds to simulate slow network connections. This can uncover bugs related to timing dependencies for network transfers. For example, a small network transfer may be implicitly assumed to finish before a large one, but that might not always be the case.
108106

109-
- When developing the page locally, perform testing by using a local web server and not just via ``file://`` URLs. The script ``emrun.py`` in Emscripten source tree is designed to serve as an ad hoc web server for this purpose. Emrun is preconfigured to handle serving gzip compressed files (with suffix ``.gz``), and enables support for the ``Large-Allocation`` header, and allows command line automation runs of compiled pages.
107+
- When developing the page locally, perform testing by using a local web server and not just via ``file://`` URLs. The script ``emrun.py`` in Emscripten source tree is designed to serve as an ad hoc web server for this purpose. Emrun is preconfigured to handle serving gzip compressed files (with suffix ``.gz``), and allows command line automation runs of compiled pages.
110108

111109
- Catch all exceptions that come from within entry points that call to compiled asm.js and WebAssembly code. There are three distinct exception classes that compiled code can throw:
112110

site/source/docs/porting/networking.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,31 @@ Direct UDP communication is not available in browsers, but as a close
9696
alternative, the WebRTC specification provides a mechanism to perform UDP-like
9797
communication with WebRTC Data Channels. Currently Emscripten does not provide a
9898
C/C++ API for interacting with WebRTC.
99+
100+
Direct Sockets API (Isolated Web Apps)
101+
=======================================
102+
103+
The `Direct Sockets API <https://wicg.github.io/direct-sockets/>`_ provides
104+
real TCP and UDP socket access from the browser, without needing a proxy server.
105+
This API is only available inside Chrome Isolated Web Apps (IWAs).
106+
107+
Emscripten can route POSIX socket syscalls through the Direct Sockets API using
108+
``TCPSocket``, ``TCPServerSocket``, and ``UDPSocket``. This enables existing
109+
C/C++ networking code (including libraries like OpenSSL and Tor) to work
110+
with real network sockets inside an IWA.
111+
112+
To enable Direct Sockets support, compile and link with
113+
``-sDIRECT_SOCKETS``. This also requires ``-sASYNCIFY`` (or JSPI).
114+
115+
The following POSIX socket functions are supported:
116+
- ``socket()``, ``bind()``, ``connect()``, ``listen()``, ``accept()``,
117+
``send()``, ``recv()``, ``sendto()``, ``recvfrom()``, ``sendmsg()``,
118+
``recvmsg()``, ``shutdown()``, ``getsockname()``, ``getpeername()``,
119+
``setsockopt()``, ``getsockopt()``, ``poll()``, ``ioctl()``,
120+
``fcntl()``, ``pipe()``, ``socketpair()``
121+
122+
WebTransport and QUIC
123+
=====================
124+
125+
WebTransport may be used to send UDP like datagrams over QUIC.
126+
Currently Emscripten does not provide a C/C++ API for interacting with WebTransport.

src/lib/libbase64.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@ addToLibrary({
88
// Decodes a _known valid_ base64 string (without validation) and returns it as a new Uint8Array.
99
// Benchmarked to be around 5x faster compared to a simple
1010
// "Uint8Array.from(atob(b64), c => c.charCodeAt(0))" (TODO: perhaps use this form in -Oz builds?)
11+
#if !JS_BASE64_API
1112
$base64Decode__postset: `
1213
// Precreate a reverse lookup table from chars
1314
// "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" back to
1415
// bytes to make decoding fast.
15-
for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), i = 25; i >= 0; --i) {
16-
base64ReverseLookup[48+i] = 52+i; // '0-9'
17-
base64ReverseLookup[65+i] = i; // 'A-Z'
18-
base64ReverseLookup[97+i] = 26+i; // 'a-z'
16+
for (var base64ReverseLookup = new Uint8Array(123/*'z'+1*/), __b64i = 25; __b64i >= 0; --__b64i) {
17+
base64ReverseLookup[48+__b64i] = 52+__b64i; // '0-9'
18+
base64ReverseLookup[65+__b64i] = __b64i; // 'A-Z'
19+
base64ReverseLookup[97+__b64i] = 26+__b64i; // 'a-z'
1920
}
2021
base64ReverseLookup[43] = 62; // '+'
2122
base64ReverseLookup[47] = 63; // '/'
2223
`,
24+
#endif
2325
$base64Decode__docs: '/** @noinline */',
2426
$base64Decode: (b64) => {
2527
#if JS_BASE64_API

0 commit comments

Comments
 (0)