Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed run-time assertion due to RiveRenderObject.dispose() not calling super.dispose() at the end of the method #335

Closed
hugovangalen opened this issue Jul 26, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@hugovangalen
Copy link

I am using Rive 0.11.6 and I noticed that RiveRenderObject.dispose() method isn't calling super.dispose() as the last method in the function, but as the first.

This causes the following failure:

I/flutter (22660): The following assertion was thrown while finalizing the widget tree:
I/flutter (22660): 'package:flutter/src/rendering/object.dart': Failed assertion: line 1644 pos 12: '!_debugDisposed':
I/flutter (22660): is not true.
I/flutter (22660): 
I/flutter (22660): When the exception was thrown, this was the stack:
I/flutter (22660): #2      RenderObject.dispose (package:flutter/src/rendering/object.dart:1644:12)
I/flutter (22660): #3      RiveRenderObject.dispose (package:rive/src/rive.dart:106:11)
I/flutter (22660): #4      RenderObjectElement.unmount (package:flutter/src/widgets/framework.dart:6221:20)

The fix for this crash is to put super.dispose() at the end of the method, as per RenderBox documentation, like so:

  @override
  void dispose() {
    _artboard.redraw.removeListener(scheduleRepaint);
    super.dispose();
  }

@hugovangalen hugovangalen added the bug Something isn't working label Jul 26, 2023
@HayesGordon
Copy link
Contributor

Hi @hugovangalen, thanks for the report.

Interesting that this hasn't popped up before as an issue. This particular code has been there for a long time.

Do you have a reproducible example that results in this crash? Regardless though we'll make the super.dispose() the last call.

@hugovangalen
Copy link
Author

I do not have a small example (yet) that triggers this error. This occured in a larger project and haven't been succesful in isolating it, so I suspect at this time it may have to do something with multiple objects nested in the render tree or something...

Admitted, I can't entirely eliminate user error, but the incorrect order in dispose() just stood out to me.

If I can successfully isolate the issue, I'll add to this ticket.

@HayesGordon
Copy link
Contributor

Thanks @hugovangalen . I'll let you know when this is updated

@andrewpmoore
Copy link

andrewpmoore commented Jul 27, 2023

Not sure when this started happening, as I've not seen it before, but it started happening for me today also. My project too I can't really isolate it as I've got a collection of Rive animations happening and it's when I'm switching between pages with rive animations running on both that it seems to happen.

rive-engineering pushed a commit that referenced this issue Aug 1, 2023
Fixes: #335

By calling `super.dispose()` at the end - as suggested in the Flutter docs for widgets + render objects.

Added the same to the editor (for widgets + render objects)

These changes _should_ not result in any issues. But I don't know if there are valid reasons for any of these to call super.dispose first - if yes, then we should investigate the underlying reason for that.

Diffs=
913760d97 chore: end with call to dispose (#5703)

Co-authored-by: Gordon <pggordonhayes@gmail.com>
@HayesGordon
Copy link
Contributor

Should be fixed in v0.11.9 - if the above was the cause of the problem. Please reopen if you encounter it again after bumping to this version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants