EsotericSoftware / spine-runtimes

2D skeletal animation runtimes for Spine.
http://esotericsoftware.com/
Other
4.26k stars 2.87k forks source link

[flutter] setState() called after dispose() #2564

Closed devSC closed 2 days ago

devSC commented 1 week ago

setState() called after dispose(): _SpineWidgetState#88538(lifecycle state: defunct, not mounted) This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose(). stack: dart-sdk/lib/_internal/js_dev_runtime/private/ddcruntime/errors.dart 294:3 throw packages/flutter/src/widgets/framework.dart 1167:9 packages/flutter/src/widgets/framework.dart 1201:14 setState packages/spine_flutter/spine_widget.dart 415:5 loadDrawable packages/spine_flutter/spine_widget.dart 421:9 loadFromAsset dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 dart-sdk/lib/async/zone.dart 1407:47 _rootRunUnary dart-sdk/lib/async/zone.dart 1308:19 runUnary dart-sdk/lib/async/future_impl.dart 162:18 handleValue dart-sdk/lib/async/future_impl.dart 846:44 handleValueCallback dart-sdk/lib/async/future_impl.dart 875:13 _propagateToListeners dart-sdk/lib/async/future_impl.dart 464:9 dart-sdk/lib/async/zone.dart 1399:13 _rootRun dart-sdk/lib/async/zone.dart 1301:19 run dart-sdk/lib/async/zone.dart 1209:7 runGuarded dart-sdk/lib/async/zone.dart 1249:23 callback dart-sdk/lib/async/schedule_microtask.dart 40:11 _microtaskLoop dart-sdk/lib/async/schedule_microtask.dart 49:5 _startMicrotaskLoop dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 181:7

badlogic commented 1 week ago

Can you illustrate this with example code? I'm having a hard time reproducing this otherwise.

badlogic commented 2 days ago

@devSC happy to re-open if you can provide more information.