Files
electron/docs/api/shared-texture.md
2025-11-07 09:50:28 +01:00

3.2 KiB

sharedTexture

Import shared textures into Electron and converts platform specific handles into VideoFrame. Supports all Web rendering systems, and can be transferred across Electron processes. Read here for more information.

Process: Main, Renderer

Methods

The sharedTexture module has the following methods:

Note: Experimental APIs are marked as such and could be removed in the future.

sharedTexture.importSharedTexture(options) Experimental

  • options Object - Options for importing shared textures.
    • textureInfo SharedTextureImportTextureInfo - The information of the shared texture to import.
    • allReferencesReleased Function (optional) - Called when all references in all processes are released. You should keep the imported texture valid until this callback is called.

Imports the shared texture from the given options.

Note

This method is only available in the main process.

Returns SharedTextureImported - The imported shared texture.

sharedTexture.sendSharedTexture(options, ...args) Experimental

  • options Object - Options for sending shared texture.
    • frame WebFrameMain - The target frame to transfer the shared texture to. For WebContents, you can pass webContents.mainFrame. If you provide a webFrameMain that is not a main frame, you'll need to enable webPreferences.nodeIntegrationInSubFrames for this, since this feature requires IPC between main and the frame.
    • importedSharedTexture SharedTextureImported - The imported shared texture.
  • ...args any[] - Additional arguments to pass to the renderer process.

Send the imported shared texture to a renderer process. You must register a receiver at renderer process before calling this method. This method has a 1000ms timeout. Ensure the receiver is set and the renderer process is alive before calling this method.

Note

This method is only available in the main process.

Returns Promise<void> - Resolves when the transfer is complete.

sharedTexture.setSharedTextureReceiver(callback) Experimental

  • callback Function<Promise<void>> - The function to receive the imported shared texture.
    • receivedSharedTextureData Object - The data received from the main process.
    • ...args any[] - Additional arguments passed from the main process.

Set a callback to receive imported shared textures from the main process.

Note

This method is only available in the renderer process.

Properties

The sharedTexture module has the following properties:

sharedTexture.subtle Experimental

A SharedTextureSubtle property, provides subtle APIs for interacting with shared texture for advanced users.