Frontmatter
| id | 8119 |
| title | Refactor Canvas interactions to RMA & Support Return Value Transfers |
| state | Closed |
| labels | enhancementairefactoringarchitecture |
| assignees | tobiu |
| createdAt | Dec 16, 2025, 12:00 AM |
| updatedAt | Dec 16, 2025, 12:46 AM |
| githubUrl | https://github.com/neomjs/neo/issues/8119 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Dec 16, 2025, 12:46 AM |
Refactor Canvas interactions to RMA & Support Return Value Transfers
tobiu assigned to @tobiu on Dec 16, 2025, 12:04 AM

tobiu
Dec 16, 2025, 12:42 AM
Input from Gemini 2.5 pro:
✦ Refactoring completed successfully.
Implementation Details:
src/worker/mixin/RemoteMethodAccess.mjs:
- Enhanced
resolve()to support a return value structure{ result: ..., transfer: [...] }.- If
transferarray is present, it unwrapsresultas the message payload and passestransfertopostMessage.- If
transferis absent, it sends the return value as-is.
src/main/DomAccess.mjs:
- Exposed
getOffscreenCanvasvia RMA.- Success case: Returns
{ result: { offscreen }, transfer: [offscreen] }.- Error case (Already Transferred): Returns
{ transferred: true }.
src/worker/Canvas.mjs:
- Exposed
registerCanvasandretrieveCanvasvia RMA.- Removed manual
sendMessagecalls.
src/component/Canvas.mjs:
- Updated to use
Neo.main.DomAccess.getOffscreenCanvasandNeo.worker.Canvas.*methods.- Logic handles the
{ transferred: true }response correctly to fallback to worker retrieval in shared worker mode.Verified with logs confirming correct data flow for both new canvas transfer and re-integration scenarios.
tobiu closed this issue on Dec 16, 2025, 12:46 AM
This is an exploration quest to refactor the manual worker messaging in the
OffscreenCanvasimplementation to useRemoteMethodAccess(RMA), and to enhance RMA to support transferring return values.Objectives
Refactor
Neo.worker.Canvasinteractions:retrieveCanvasandregisterCanvasinsrc/worker/Canvas.mjsto be exposed via theremoteconfig.src/component/Canvas.mjsto call these methods directly via the proxy (e.g.,Neo.worker.Canvas.retrieveCanvas(...)) instead of usingpromiseMessage.Enhance
Neo.worker.mixin.RemoteMethodAccess:resolvemethod in RMA does not support defining atransferarray for the return value. This preventsNeo.main.DomAccess.getOffscreenCanvasfrom being converted to RMA, as it needs to transfer theOffscreenCanvasback to the caller.src/worker/mixin/RemoteMethodAccess.mjs(specifically theresolveandonRemoteMethodlogic) to detect if a return value includes transferables (e.g., via a specific return structure like{ data: result, transfer: [...] }) and handle the message posting with the transfer list accordingly.Benefits
promiseMessageconstruction).Context
Discussion originated from the refactoring of OffscreenCanvas support for shared workers (#8118).