Fix VoiceOver performance lag with large libraries#1489
Open
matalvernaz wants to merge 1 commit intoTortugaPower:developfrom
Open
Fix VoiceOver performance lag with large libraries#1489matalvernaz wants to merge 1 commit intoTortugaPower:developfrom
matalvernaz wants to merge 1 commit intoTortugaPower:developfrom
Conversation
Three changes to reduce main-thread work when VoiceOver is active: 1. DynamicAccessibilityLabelModifier: skip setupObserver() for items that are neither currently playing nor have an active subscription. Previously every item in the library called getAccessibilityLabel() (string formatting + time math) whenever the playing track changed. 2. ItemProgressView: throttle immediateProgressUpdatePublisher at 1s, matching the existing throttle on folderProgressUpdated. Rapid-fire progress events no longer cause per-frame state writes on all cells. 3. ItemListView custom rotors: use item.title instead of calling getAccessibilityLabel() for every item on each rotor rebuild. The rich label is already applied by dynamicAccessibilityLabel(); the rotor entry only needs the title for navigation.
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.
Problem
When VoiceOver is enabled and a large number of books are loaded, the library list becomes noticeably laggy. Three separate issues compound to cause this:
DynamicAccessibilityLabelModifierrecomputes labels for every item on track change — theonChange(of: playerManager.currentItem?.relativePath)handler callssetupObserver()unconditionally on every item in the list. For non-playing items this synchronously callsVoiceOverService.getAccessibilityLabel(), which does time arithmetic andlocalizedStringWithFormatwith multiple arguments. With 100+ books this fires O(n) times on the main thread every time playback starts/stops/changes.Custom accessibility rotors call
getAccessibilityLabelfor all items on every rebuild —customBookRotorandcustomFolderRotorpassVoiceOverService.getAccessibilityLabel(for: item)as the rotor entry label for every item. Rotors are rebuilt wheneverfilteredResultschanges, and VoiceOver triggers these rebuilds frequently during navigation.immediateProgressUpdatePublisherinItemProgressViewis unthrottled — thefolderProgressUpdatedsubscription is throttled to 1s butimmediateProgressUpdatePublisheris not, so rapid-fire progress writes hit every visible cell immediately.Changes
DynamicAccessibilityLabelModifier: skipsetupObserver()in theonChangehandler for items that are neither currently playing nor have an active subscription. The expensive label recomputation now only runs for the one item that just started or stopped playing.ItemListViewcustom rotors: useitem.titleas the rotor entry label instead of callinggetAccessibilityLabel(). The full rich label (with remaining time, progress %) is already applied bydynamicAccessibilityLabel()on each row — the rotor list only needs the title for navigation purposes.ItemProgressView: add.throttle(for: .seconds(1), scheduler: DispatchQueue.main, latest: true)to theimmediateProgressUpdatePublishersubscription, consistent with the existing throttle onfolderProgressUpdated.Testing