Fix karaoke highlight crash when editing the transcript#295
Merged
Conversation
When the editor deletes spans, the library's cached wordArr still references the now-detached nodes until the debounced refresh rebuilds it. If the library's setTimeout poll fires inside that window, updateTranscriptVisualState dereferences word.n.parentNode.classList on a node whose parentNode is null and the rejection kills the polling chain — the karaoke highlight freezes for the rest of the session. Monkeypatch updateTranscriptVisualState on the HyperaudioLite instance to filter wordArr to live entries before delegating to the original. The library only uses wordArr via a fresh binary search per call, so a temporarily shrunken array is consistent. The next debounced refreshHyperaudioInstance rebuilds wordArr fully from the live DOM. Fixes #294.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
When the user deletes spans in the transcript while playback is running,
hyperaudio-lite's cachedwordArrstill references the now-detached nodes. If itssetTimeoutpoll fires before the editor's debouncedrefreshHyperaudioInstancerebuilds the array,updateTranscriptVisualStatedereferencesword.n.parentNode.classListon a node whoseparentNodeisnull— the rejection happens inside thesetTimeoutcallback so the polling chain dies silently, freezing the karaoke highlight for the rest of the session.Monkeypatches
updateTranscriptVisualStateon theHyperaudioLiteinstance to filterwordArrto live entries before delegating to the original. The library only useswordArrvia a fresh binary search per call, so a temporarily shrunken array is consistent. The next debouncedrefreshHyperaudioInstancerebuildswordArrfully from the live DOM.Kept the fix in the editor rather than upstream because the race only exists for editor-style consumers that mutate the transcript DOM at runtime;
hyperaudio-liteis otherwise read-only.Fixes #294.
Test plan
restoreTranscript— confirm the patch is applied to the freshHyperaudioLiteinstance (re-applied on everyhyperaudio()call).