perf: coalesce watch together rebuilds, static TV overlays

This commit is contained in:
edde746
2026-03-25 06:40:17 +01:00
parent 4beeedd318
commit 4cef99dda2
4 changed files with 80 additions and 42 deletions
@@ -30,6 +30,21 @@ class WatchTogetherProvider with ChangeNotifier {
String _displayName = 'User';
String? _lastHandledCurrentPlaybackKey;
// Coalesce rapid-fire notifyListeners() calls into a single rebuild per frame.
// During Watch Together join, 4-5 notifications fire within milliseconds;
// this batches them into one rebuild to avoid overwhelming low-end devices.
bool _notifyScheduled = false;
@override
void notifyListeners() {
if (_notifyScheduled) return;
_notifyScheduled = true;
scheduleMicrotask(() {
_notifyScheduled = false;
super.notifyListeners();
});
}
// Host reconnect grace period
Timer? _hostReconnectTimer;
bool _isWaitingForHostReconnect = false;