-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix player position performance issue #606
Conversation
@@ -48,7 +48,6 @@ class PlayerControls extends HookConsumerWidget { | |||
|
|||
final playing = | |||
useStream(audioPlayer.playingStream).data ?? audioPlayer.isPlaying; | |||
final buffering = useStream(audioPlayer.bufferingStream).data ?? true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no clue why, but this is also causing re-renders
@@ -89,215 +88,208 @@ class PlayerControls extends HookConsumerWidget { | |||
iconSize: compact ? 18 : 24, | |||
); | |||
|
|||
return RepaintBoundary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only RepaintBoundary
and buffering
removed
@@ -62,99 +62,95 @@ class PlayerOverlay extends HookConsumerWidget { | |||
child: AnimatedOpacity( | |||
duration: const Duration(milliseconds: 250), | |||
opacity: canShow ? 1 : 0, | |||
child: RepaintBoundary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only RepaintBoundary
removed
// Duration future is needed for getting the duration of the song | ||
// as stream can be null when no event occurs (Mostly needed for android) | ||
final durationFuture = useFuture(audioPlayer.duration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
both useFuture
s cause hook to re-create every tick
@@ -9,21 +8,29 @@ import 'package:spotube/services/audio_player/audio_player.dart'; | |||
Duration duration, | |||
double bufferProgress | |||
}) useProgress(WidgetRef ref) { | |||
final playlist = ref.watch(ProxyPlaylistNotifier.provider); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused
That's awesome work 🚀. Let me quickly check |
Fixes #507
I'm not sure whether this is a correct fix and why it's not present on all platforms, devtools show re-renders every tick:
After this fix, when the song is playing, re-render only happens ever 1s (update freq of the position slider), when the song is stopped - zero re-renders