Skip to content

Cache waveform peaks and use direct URLs for faster replay loads#1223

Open
hilsonshrestha wants to merge 5 commits intodevfrom
1174-replay-videos-should-load-faster
Open

Cache waveform peaks and use direct URLs for faster replay loads#1223
hilsonshrestha wants to merge 5 commits intodevfrom
1174-replay-videos-should-load-faster

Conversation

@hilsonshrestha
Copy link
Copy Markdown
Contributor

@hilsonshrestha hilsonshrestha commented May 7, 2026

Does this PR close any open issues?

Closes #1174

Give a longer description of what this PR addresses and why it's needed

Audio and screen recording replays were slow because WaveSurfer had to fully decode audio on every load to render the waveform. This PR caches decoded waveform peaks to storage after the first load so subsequent visits skip decoding. It also replaces entire blob fetches of audio and video with direct URL calls so that the media player can buffer stream.

PR also shows a warning when participant used a browser different.

Provide pictures/videos of the behavior before and after these changes (optional)

image

Are there any additional TODOs before this PR is ready to go?

x

Copilot AI review requested due to automatic review settings May 7, 2026 14:17
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

A preview of c1958fe is uploaded and can be seen here:

https://revisit.dev/study/PR1223

Changes may take a few minutes to propagate.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves replay performance by avoiding repeated full audio decode for waveform rendering and by switching replay media loading from full-blob fetches to direct URLs so the browser can stream/buffer.

Changes:

  • Added support for caching/loading WaveSurfer waveform peaks via the storage engine.
  • Updated replay components to use direct screen recording URLs instead of blob/object URLs.
  • Updated audio provenance visualization to load cached peaks when available and persist peaks after first load.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/storage/engines/types.ts Adds WaveformPeaks type + storage helpers for saving/loading cached peaks; adds screen recording URL getter.
src/components/screenRecording/ScreenRecordingReplay.tsx Switches screen recording replay source to direct URL loading.
src/components/audioAnalysis/AudioProvenanceVis.tsx Adds waveform peak caching logic and switches to direct media URLs for faster load.
src/analysis/individualStudy/thinkAloud/ThinkAloudFooter.tsx Switches think-aloud footer screen recording load to direct URL.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

.catch((err) => console.warn('Failed to save waveform peaks:', err));
});

await waveSurfer.load(audioUrl, undefined, duration);
Comment on lines +936 to +939
async getWaveformPeaks(taskName: string, participantId: string): Promise<WaveformPeaks | null> {
const result = await this._getFromStorage(`audio/${participantId}_${taskName}`, 'waveform.peaks.json');
if (!result || !('peaks' in result)) return null;
return result as WaveformPeaks;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants