diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 638bcdedc..7374b424a 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -3642,8 +3642,9 @@ class CursorModel with ChangeNotifier { } /// Native cursors of the peer's shapes kept, the ones used last; the core rebuilds the - /// others. Covers the everyday set: arrow, text, hand, four resize arrows, wait and a few. - static const kMaxNativeCursors = 16; + /// others. An animated cursor is a shape per frame, 18 for the Windows busy cursor and 23 + /// for KDE's, and a cycle longer than this limit would rebuild every frame. + static const kMaxNativeCursors = 64; // `_nativeKeys` is in order of use. The predefined cursors are not the peer's and stay. void _evictNativeKeys() { diff --git a/flutter/test/cursor_replay_test.dart b/flutter/test/cursor_replay_test.dart index b44f3ac5a..5112bf6ce 100644 --- a/flutter/test/cursor_replay_test.dart +++ b/flutter/test/cursor_replay_test.dart @@ -52,7 +52,7 @@ void _select(_FFI ffi, String id) { } Future _settle() async { - for (var i = 0; i < 20; i++) { + for (var i = 0; i < 2; i++) { await Future.delayed(const Duration(milliseconds: 5)); } } @@ -174,6 +174,28 @@ void main() { expect(registered.length - deleted.length, max); }); + test('an animated cursor cycles without decoding a frame again', () async { + // Each frame is a shape of its own: 18 for the Windows busy cursor, 23 for + // KDE Breeze's wait cursor on X11. + const frames = 23; + final cursor = ffi.cursorModel; + for (var i = 0; i < frames; i++) { + await _feed(ffi, '$i', seed: i); + buildCursorOfCache(cursor, 1.0, cursor.cache); + await _settle(); + } + ffi.cursor.fetched.clear(); + for (var i = 0; i < frames; i++) { + _select(ffi, '$i'); + buildCursorOfCache(cursor, 1.0, cursor.cache); + await _settle(); + } + expect(ffi.cursor.fetched, isEmpty, + reason: 'every frame kept its native cursor'); + expect(registered.length, frames); + expect(deleted, isEmpty); + }); + test('a shape painted again is decoded again from the core', () async { await _feed(ffi, '1', size: 16); await _feed(ffi, '2');