perf: Implement zero-copy audio transfer and optimize scroll#141
Conversation
- Reorder AudioEngine callbacks to enable buffer transfer - Update TranscriptionWorkerClient to use Transferable - Debounce scrollToBottom in TranscriptionDisplay Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Code Review SummaryStatus: No Issues Found | Recommendation: Merge OverviewThis PR implements performance optimizations focused on zero-copy buffer transfers and scroll behavior improvements:
Changes Reviewed
Technical Notes
Files Reviewed (3 files)
Review generated by Kilo Code Review Agent |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4b7484c386
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| containerRef.scrollTop = containerRef.scrollHeight; | ||
| } | ||
| }); | ||
| scrollTimeout = undefined; |
There was a problem hiding this comment.
Keep debounce armed until scroll frame executes
scrollTimeout is cleared immediately after scheduling requestAnimationFrame, which means in background tabs (where RAF is paused) each incoming mutation can enqueue another RAF callback while transcription continues. When the tab becomes visible again, those queued callbacks can run in a burst and cause avoidable jank/memory growth; keeping the debounce state set until the RAF callback runs avoids this regression.
Useful? React with 👍 / 👎.
|
Related follow-up landed in PR #143 (conservative round-2 perf pass). It focuses on low-risk v4 worker/UI/debug optimizations and references this PR as related context. |
This change addresses two performance issues:
AudioEngine.tsto callaudioChunkCallbacksafter internal processing (RingBuffer write, VAD, Vis). This allows subscribers (like TenVAD worker) to transfer the audio buffer without detaching it before the engine uses it.TranscriptionWorkerClient.tsto support transferring buffers (Transferable[]) insendRequest.processV4ChunkWithFeatures,processV3ChunkWithFeatures, andprocessV3Chunkto transfer large buffers (features,audio) instead of copying them.TranscriptionDisplay.tsxby adding a 50ms debounce toscrollToBottomand explicitly disablingcharacterDataobservation inMutationObserver. This prevents excessive layout thrashing during rapid text streaming.Verified with
mel-e2e.test.tsand a temporary reproduction test forAudioEngine.PR created automatically by Jules for task 13074619647761767215 started by @ysdede