Repository navigation
electron shared texture #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jspanchu
wants to merge
12
commits into
master
Choose a base branch
from
electron-shared-texture
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5440d7e
chore(deps): bump minimum python version to 3.10
jspanchu 61a6b9f
feat(electron-shared-texture): Add new electron shared texture display
jspanchu 91cda4e
fix(electron): add profiler for render and flush
jspanchu 0b39070
fix(example): enable profiler in electron example
jspanchu c37f348
fix(windows): set timer resolution to 1ms
jspanchu 42c5512
fix(js): convert from CJS to module JS
jspanchu ba4b112
fix(rca): move init function trame_rca.widgets
jspanchu da1e851
fix(rca): do not render in render window getter
jspanchu 912c361
fix(shared-texture): use ring of textures to reduce latency
jspanchu ec3cd50
docs(example): add native desktop app for comparison
jspanchu c159b29
docs(example): add point cloud streaming example
jspanchu 2f756ce
feat(shared-texture): support multiple views
jspanchu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| [codespell] | ||
| skip = **/package-lock.json,CHANGELOG.md | ||
| ignore-words-list = renderd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /* eslint-env node */ | ||
| module.exports = { | ||
| root: true, | ||
| env: { | ||
| node: true, | ||
| browser: true, | ||
| es2022: true, | ||
| }, | ||
| extends: ['eslint:recommended'], | ||
| parserOptions: { | ||
| ecmaVersion: 'latest', | ||
| sourceType: 'module', | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| node_modules/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| # @kitware/trame-rca-electron | ||
|
|
||
| Shows trame-rca `display="shared-texture"` views in Electron. The trame server renders VTK | ||
| into a GPU texture, and this package hands it to the page without encoding, or copying to the CPU. | ||
|
|
||
| This package and the `trame-rca` python package speak a versioned protocol (see | ||
| `src/main/protocol.js` and `trame_rca/electron/comm.py`): use matching releases. | ||
|
|
||
| ## Use | ||
|
|
||
| ```js | ||
| import { app, BrowserWindow } from 'electron/main'; | ||
| import { launchTrame, webPreferences } from '@kitware/trame-rca-electron'; | ||
|
|
||
| app.whenReady().then(() => { | ||
| const win = new BrowserWindow({ webPreferences: webPreferences() }); | ||
| launchTrame(win, { command: 'python3', args: ['app.py'], onExit: () => app.quit() }); | ||
| }); | ||
| ``` | ||
|
|
||
| `launchTrame(win, options)` spawns `command` with `args` plus `--server --port 0 --emp-port <port>`, | ||
| and loads the page in `win` once trame serves it. Options: | ||
|
|
||
| - `command`, `args`, `cwd`, `env`: the trame server to run. Any executable works: a python | ||
| interpreter and a script, a frozen backend, etc. | ||
| - `onExit(code, signal)`: the server exited. | ||
| - `onStats({ view, fps, frames, info })`: once a second, per shared-texture view that drew frames. | ||
| - `log`: defaults to `console`. | ||
|
|
||
| It returns `{ process, close }`. `close()` kills the server; it is called when `win` closes. | ||
|
|
||
| `webPreferences(extra)` sets the preload, and turns off the sandbox: the preload needs | ||
| `sharedTexture`, and Electron doesn't run ES module preloads in a sandbox. If the window needs its | ||
| own preload, `import '@kitware/trame-rca-electron/preload'` from it: it must then be an ES module | ||
| preload too, with the `.mjs` extension. | ||
|
|
||
| On the python side, see `examples/06_electron` in trame-rca. | ||
|
|
||
| ## Packaging an app | ||
|
|
||
| Packaging (electron-builder or Forge, a frozen python backend, signing) belongs to each app. | ||
| What this package needs from a packaged app: | ||
|
|
||
| - `koffi` is a native module: unpack it from the asar archive (e.g. electron-builder's | ||
| `asarUnpack: ["**/node_modules/koffi/**"]`). | ||
| - Pass the packaged backend as `command`. It must be spawned by `launchTrame`, as a direct child | ||
| of the main process: on Linux, duplicating its dma-buf file descriptors needs ptrace access to | ||
| it (`kernel.yama.ptrace_scope` at 1 or less). | ||
| - The frozen backend must include `vtkmodules` and the `serve` directories of `trame_rca` and of | ||
| every other trame package it uses. | ||
| - macOS shares the texture as a global IOSurface, which does not work in an App Sandbox (so not on | ||
| the Mac App Store). | ||
| - Linux: X11 is not supported yet, Electron must run under Wayland. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.