perf: don't create thumbnails when auto-saving
When note is autosaved, there is no need to create a thumbnail which causes small lag during hang writing.
New SavingState.savedNeedThumbnailUpdate state is implemented indicating that note is saved but thumbnail is not created.
On editor exit is checked this state and thumbnail is created.
PreviewCard fileWriteListener is listening to write to thumbnail file to be able to detect change of thumbnail itself.
Closes #1164 (or at least lag is smaller)
Codecov Report
Attention: Patch coverage is 32.55814% with 29 lines in your changes are missing coverage. Please review.
Project coverage is 36.96%. Comparing base (
a74d961) to head (fb38bf1). Report is 7 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #1175 +/- ##
==========================================
- Coverage 37.50% 36.96% -0.54%
==========================================
Files 108 108
Lines 8554 8576 +22
==========================================
- Hits 3208 3170 -38
- Misses 5346 5406 +60
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Drawing something and clicking save gives me this error:
Launching lib/main.dart on Linux in debug mode...
Building Linux application...
Syncing files to device Linux... 205ms
Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
A Dart VM Service on Linux is available at: http://127.0.0.1:41135/rKfNL5wM7bs=/
The Flutter DevTools debugger and profiler on Linux is available at:
http://127.0.0.1:9101?uri=http://127.0.0.1:41135/rKfNL5wM7bs=/
flutter: dynamic_color: Accent color detected.
flutter: INFO: FileSyncer: Adding /24-03-18 Untitled.sbn2 to upload queue
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY
╞═══════════════════════════════════════════════════════════
The following assertion was thrown building Directionality(textDirection: ltr):
'package:flutter/src/widgets/framework.dart': Failed assertion: line 2115 pos 12:
'_elements.contains(element)': is not true.
Either the assertion indicates an error in the framework itself, or we should
provide substantially
more information in this error message to help you determine and fix the underlying
cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.yml
The relevant error-causing widget was:
Directionality
Directionality:file:///home/ahann/.pub-cache/hosted/pub.dev/screenshot-2.1.0/lib/
screenshot.dart:189:20
When the exception was thrown, this was the stack:
#2 _InactiveElements.remove
(package:flutter/src/widgets/framework.dart:2115:12)
#3 Element._retakeInactiveElement
(package:flutter/src/widgets/framework.dart:4266:30)
... Normal element mounting (7 frames)
#10 Element.inflateWidget (package:flutter/src/widgets/framework.dart:4335:16)
#11 Element.updateChild (package:flutter/src/widgets/framework.dart:3846:18)
#12 RenderObjectToWidgetElement._rebuild
(package:flutter/src/widgets/adapter.dart:143:16)
#13 RenderObjectToWidgetElement.mount
(package:flutter/src/widgets/adapter.dart:112:5)
#14 RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure>
(package:flutter/src/widgets/adapter.dart:61:18)
#15 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2844:19)
#16 RenderObjectToWidgetAdapter.attachToRenderTree
(package:flutter/src/widgets/adapter.dart:60:13)
#17 ScreenshotController.widgetToUiImage
(package:screenshot/screenshot.dart:192:16)
#18 ScreenshotController.captureFromWidget
(package:screenshot/screenshot.dart:106:28)
#19 EditorState.createThumbnailPreview
(package:saber/pages/editor/editor.dart:890:43)
#20 EditorState.saveToFile (package:saber/pages/editor/editor.dart:875:32)
<asynchronous suspension>
(elided 2 frames from class _AssertionError)
═══════════════════════════════════════════════════════════════════════════════════
═════════════════
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.
#0 Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/framework.dart:4738:9)
#1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:4752:6)
#2 Element.dependOnInheritedWidgetOfExactType (package:flutter/src/widgets/framework.dart:4771:12)
#3 ModalRoute.of (package:flutter/src/widgets/routes.dart:1046:47)
#4 GoRouterState.of (package:go_router/src/state.dart:119:51)
#5 _RecentPageState.findRecentlyAccessedNotes (package:saber/pages/home/recent_notes.dart:90:38)
#6 _RecentPageState.fileWriteListener (package:saber/pages/home/recent_notes.dart:80:5)
#7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#9 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#10 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#11 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#12 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.
#0 Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/framework.dart:4738:9)
#1 Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:4752:6)
#2 Element.dependOnInheritedWidgetOfExactType (package:flutter/src/widgets/framework.dart:4771:12)
#3 ModalRoute.of (package:flutter/src/widgets/routes.dart:1046:47)
#4 GoRouterState.of (package:go_router/src/state.dart:119:51)
#5 _RecentPageState.findRecentlyAccessedNotes (package:saber/pages/home/recent_notes.dart:90:38)
#6 _RecentPageState.fileWriteListener (package:saber/pages/home/recent_notes.dart:80:5)
#7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
#8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#9 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#10 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#11 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#12 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
Another exception was thrown: Duplicate GlobalKey detected in widget tree.
flutter: INFO: FileSyncer: Adding /24-03-18 Untitled.sbn2.p to upload queue
flutter: dynamic_color: Accent color detected.
Performing hot reload...
Reloaded 1 of 3368 libraries in 4,884ms (compile: 53 ms, reload: 4478 ms,
reassemble: 194 ms).
Lost connection to device.
I will try to look at this problem.