From f48b6c0d721b03ef7bfdbf76625253ee52326dea Mon Sep 17 00:00:00 2001 From: rustdesk Date: Fri, 25 Sep 2026 11:55:39 +0800 Subject: [PATCH] cursor: say what Future.sync defers, and give the default cursor time on a slow runner The comment on the fetch in restorePixels read as if the fetch were put off; it runs at once, and Future.sync only turns its throw into an error the await hands over later, which is what keeps the notify out of the build. cursor_default_test gave the default cursor 100 ms to decode, which a slow runner may miss. It cannot wait for the cursor itself, since asking for it would make it; it now waits 500 ms. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01EZ49AbZJYfm8NTp5yDPMab --- flutter/lib/models/model.dart | 3 ++- flutter/test/cursor_default_test.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 5b82a44bc..6653dddf8 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -3742,7 +3742,8 @@ class CursorModel with ChangeNotifier { final generation = _generation; () async { try { - // Never at once: a build may be what asked, and a failure tells the listeners. + // A throw becomes an error the await hands over later, not during the build that may + // have asked: a failure tells the listeners. final shape = await Future.sync(() => fetchCursorShape(id)); if (generation != _generation) { return; diff --git a/flutter/test/cursor_default_test.dart b/flutter/test/cursor_default_test.dart index 07f4fdc6c..1357a6802 100644 --- a/flutter/test/cursor_default_test.dart +++ b/flutter/test/cursor_default_test.dart @@ -54,7 +54,8 @@ void main() { final evt = {'id': '2'}; ffi.ffiModel.updateLastCursorId(evt); ffi.ffiModel.handleCursorId(evt); - await Future.delayed(const Duration(milliseconds: 100)); + // Not a wait for the default cursor itself: asking for it would make it. + await Future.delayed(const Duration(milliseconds: 500)); expect(cursor.cache, isNull); final built = _key(buildCursorOfCache( cursor, 1.0, cursor.cache ?? preDefaultCursor.cache));