Repository navigation
Backlog
Description
Bug Report 🐛
On macOS, Studio starts a "prewarmed" native file picker (osascript -l JavaScript, the RemotionFilePickerPositioner script in @remotion/studio-server/dist/native-file-picker.js) on every HTML page load. Two problems together left orphaned osascript processes at ~45–60% CPU each, running for hours after Studio had stopped (six of them, from automated Studio checks):
- The prewarmed
osascriptoutlives Studio when Studio gets SIGTERM or SIGKILL.- The prewarm is triggered in
routes.js(handleFallback, ~line 118) for any loopback GET whoseAcceptcontainstext/html. A headless browser loading the page is enough, with no click on any picker. - The child is spawned non-detached with piped stdio, and then unref'd (
native-file-picker.jslines ~103–151). - Cleanup is only
process.once('exit', () => child.kill())andcloseNativeFilePicker()on server close. The CLI handles only SIGINT (studio-shortcuts.js), sokill <pid>(SIGTERM) or SIGKILL skips both, and the child is reparented to PID 1.
- The prewarm is triggered in
- On this machine, the script never gets past
ObjC.registerSubclass.sampleshows 730 of 731 samples inObjC.registerSubclass→ffi_closure_alloc→dlmmap(libffi looping on mkostemp/mmap/unlink). So the child never reaches its stdin read, and it spins even while Studio is alive. A minimal standalone JXA script with only oneObjC.registerSubclasscall (one method) spins the same way at ~55% CPU, so the spin itself looks like an OS/JXA issue. But Studio starts it with no timeout on every page load, and nothing ends it.
Reproduction
npx remotion studio src/index.ts --no-open --port=3500 &
STUDIO=$!
sleep 10
curl -s -H 'Accept: text/html' http://localhost:3500/ > /dev/null
sleep 5
pgrep -fl RemotionFilePickerPositioner # one osascript, already at high CPU
kill $STUDIO # SIGTERM
sleep 2
ps -o pid,ppid,%cpu,command -p $(pgrep -f RemotionFilePickerPositioner) # PPID 1, still spinningResults by how Studio is stopped:
| stop | prewarmed osascript |
|---|---|
| SIGTERM to the Studio pid | orphaned (PPID 1), 47–60% CPU |
| SIGKILL to the Studio pid | orphaned (PPID 1), 62% CPU |
| SIGINT to the Studio pid | gone |
| SIGTERM to the process group | gone |
A request without an Accept: text/html header spawns nothing.
Environment
- Remotion /
@remotion/studio-server4.0.547. The file first appears in 4.0.542 (@remotion/studio: Add OpenTimelineIO import #12580).native-file-picker.tsonmainis unchanged. - macOS 26.7.3, x86_64. Node v24.16.0.
- Not run over SSH (with
SSH_CONNECTIONset, the native picker is disabled, so there is no prewarm).
Suggestions
- Start the picker on demand, not on every page load. Or give the prewarmed child a timeout.
- Handle SIGTERM and SIGHUP like SIGINT. Or spawn the child so that it dies with the parent (for example, a watchdog that exits on stdin EOF before
registerSubclass). - Add an option or env flag to turn off the native picker.
Metadata
Metadata
Assignees
Labels
No labels
Activity