fix: keep spectrogram shades aligned by drawing them once over the image - #586
Conversation
…ever flash over the preview
… and drop the player regions plugin
There was a problem hiding this comment.
Pull request overview
Fixes spectrogram shade alignment and persistence by decoupling detection shades from playback.
Changes:
- Draws responsive, percentage-positioned shades over card and modal images.
- Removes the WaveSurfer regions plugin and playback lifecycle glue.
- Uses audio metadata with a 60-second fallback for shade positioning.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
ai-for-orcas.js |
Implements persistent image-overlay shades and simplifies players. |
_Host.cshtml |
Removes the unused regions plugin script. |
DetectionComponent.razor.cs |
Updates JavaScript interop and region serialization. |
DetectionComponent.razor |
Removes obsolete region data attributes. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
I found an issue when running locally with your PR. While window is not maximized, start playing a sample and then pause it, so progress line is visible. Now change the horizontal size of the window slightly. As you do, a bar across the bottom of the spectrogram will blink as it switches back and forth between present and not present as you drag. |
|
Good catch, thanks. That bar is the player's horizontal scrollbar. wavesurfer creates its wave element with overflow-x auto, and while dragging the canvas width can briefly overflow the container by a pixel, so the scrollbar flickers in and out. I couldn't reproduce it at first because Chrome's overlay scrollbars take no space; your screenshot showed the classic style, which made it visible. Fixed by passing hideScrollbar: true to both players. The scrollbar was never functional there since the waveform always fills its parent. While testing this I found a pre-existing problem in the same area: with playback paused, the progress line drifts off its position for a moment during the drag and snaps back when wavesurfer's debounced redraw fires. It happens in production too, independent of this PR. Fixed by redrawing the player on each resize event. Both changes are pushed. |
Fixes #578
Problem
The detection shades were drawn by two different systems: static strips over the spectrogram image before playback, and wavesurfer's regions plugin once a player was active. Every symptom in #578 comes from the handoff between the two:
readyevent. On a slow connection that window lasts seconds. This also happens in production today, it is just hard to notice without the static strips next to it.Change
Make the image shades the single source of truth and remove the regions plugin:
DrawRegionShadesdraws percentage-positioned strips over the spectrogram image, for the card and the modal, once. Percentage units mean they track the responsive image through any resize or zoom with no JS resize handling.<audio preload="metadata">probe, with a 60 second fallback (the inference segment size) if the audio fails to load, so shades still appear when the clip is unreachable.Region drag/resize was already disabled, so no interactive behavior is lost by dropping the plugin.
How to test