Skip to content

[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.#26526

Open
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:audio_worklet_getentropy
Open

[AUDIO_WORKLET] Fix getentropy when called from an audio worklet.#26526
sbc100 wants to merge 1 commit intoemscripten-core:mainfrom
sbc100:audio_worklet_getentropy

Conversation

@sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Mar 23, 2026

Fixes: #26522, #13224

@sbc100 sbc100 requested review from cwoffenden, hoodmane and kripken and removed request for hoodmane March 23, 2026 23:42
@sbc100 sbc100 force-pushed the audio_worklet_getentropy branch from 0c8a5a5 to 19dc84b Compare March 23, 2026 23:53
Copy link
Member

@kripken kripken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm otherwise

random_get__deps: ['$randomFill'],
random_get: (buffer, size) => {
randomFill(HEAPU8.subarray(buffer, buffer + size));
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The moving of 0 seems to hurt code size iiuc? What is the benefit to this part?

Copy link
Collaborator Author

@sbc100 sbc100 Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change randomFill can (and does) return and error code. That is the fix here.

I guess there is 2 byte difference because in the normal case I now use the comma expression. I can't think of a cleaner way to do this and since its only 2 bytes I think its fine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW the reason randomFill happens to be included in all the codesize tests is that the FS object depends on it to do FS.createDevice('/dev', 'urandom', randomByte);.. so all programs that use the filesystem pull this in.

@sbc100 sbc100 force-pushed the audio_worklet_getentropy branch from 19dc84b to 15ba984 Compare March 24, 2026 00:05
@sbc100 sbc100 force-pushed the audio_worklet_getentropy branch from 15ba984 to 5d0310a Compare March 24, 2026 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crypto is not available inside AudioWorkletGlobalScope

2 participants