Skip to content

Add canvas transfer API for next thread#26464

Open
stevennyman wants to merge 1 commit intoemscripten-core:mainfrom
stevennyman:std-thread-next-thread-transferred-canvases
Open

Add canvas transfer API for next thread#26464
stevennyman wants to merge 1 commit intoemscripten-core:mainfrom
stevennyman:std-thread-next-thread-transferred-canvases

Conversation

@stevennyman
Copy link
Copy Markdown

@stevennyman stevennyman commented Mar 17, 2026

Useful for thread creation APIs such as std::thread or boost::thread that do not let you pass a pthread_attr_t and therefore cannot use emscripten_pthread_attr_settransferredcanvases() for transferring canvases. Fixes #10307.

The APIs added to <emscripten/threading.h> are emscripten_set_next_thread_transferredcanvases(const char* str) and emscripten_get_next_thread_transferredcanvases(const char** str). This PR also adds a test case and documentation.

(Note: I worked with an LLM while preparing this PR and made adjustments as needed.)

@stevennyman
Copy link
Copy Markdown
Author

Following up since it's been some time

@kripken
Copy link
Copy Markdown
Member

kripken commented Mar 27, 2026

Seems reasonable to me. @sbc100 @juj any thoughts?

Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 left a comment

Choose a reason for hiding this comment

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

Seems a little clunky.. but maybe there not a more elegant way to do this?

How about providing a way to transfer canvas after thread creation?

@stevennyman stevennyman force-pushed the std-thread-next-thread-transferred-canvases branch 2 times, most recently from 226f855 to ad65e2d Compare March 27, 2026 19:13
Useful for thread creation APIs that do not let you pass a pthread_attr_t. Fixes emscripten-core#10307.
@stevennyman stevennyman force-pushed the std-thread-next-thread-transferred-canvases branch from ad65e2d to 8a439eb Compare March 27, 2026 23:07
@stevennyman
Copy link
Copy Markdown
Author

Seems a little clunky.. but maybe there not a more elegant way to do this?

How about providing a way to transfer canvas after thread creation?

Based on #10307 (comment) it appears that it might not be straightforward to implement canvas transfer methods after thread creation unless there have been changes since that comment was made.

@stevennyman stevennyman force-pushed the std-thread-next-thread-transferred-canvases branch 2 times, most recently from 73a90db to 8a439eb Compare March 27, 2026 23:41
@stevennyman
Copy link
Copy Markdown
Author

CI failures seem to be for unused variables in parts of the codebase not modified by this PR. I'm not sure why.

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.

emscripten_pthread_attr_settransferredcanvases with std::thread

3 participants