Skip to content

Crash if you reuse a PictureRecorder or Canvas #2531

Closed

Description

@Hixie
import 'dart:ui';
void main() {
  Rect bounds = new Rect.fromLTWH(0.0, 0.0, 1.0, 1.0);
  PictureRecorder recorder = new PictureRecorder();
  Canvas c1 = new Canvas(recorder, bounds);
  Picture p1 = recorder.endRecording();
  Canvas c2 = new Canvas(recorder, bounds); // should throw here
  Picture p2 = recorder.endRecording(); // currently crash here
}

I would instead expect an exception when creating c2.

Activity

  1. added
    c: crashStack traces logged to the console
    engineflutter/engine related. See also e: labels.
    on Mar 9, 2016
  2. added this to the milestone on Mar 9, 2016
  3. Hixie commented on Mar 9, 2016

    @Hixie
    ContributorAuthor

    (Also I'd expect isRecording to throw in that case too.)

  4. modified the milestones: 3: Current Milestone, on Jun 12, 2017
  5. Hixie commented on Jun 12, 2017

    @Hixie
    ContributorAuthor

    I just ran into a similar crash:

    import 'dart:ui';
    
    void main() {
      Rect bounds = new Rect.fromLTWH(0.0, 0.0, 1.0, 1.0);
      PictureRecorder recorder = new PictureRecorder();
      Canvas c1 = new Canvas(recorder, bounds);
      c1.save();
      Picture p1 = recorder.endRecording();
      c1.restore(); // should throw here, currently crash here
    }

    That second one is actually pretty serious since it's one you'll run into if you forget to make your render object composited, which is an easy error to make.

    We should probably address both of these so that people experimenting with layers don't accidentally crash the engine.

  6. modified the milestones: , 3: Current Milestone on Jun 13, 2017
  7. changed the title [-]Crash if you reuse a PictureRecorder[/-] [+]Crash if you reuse a PictureRecorder or Canvas[/+] on Jun 13, 2017
  8. Hixie commented on Jun 15, 2017

    @Hixie
    ContributorAuthor
  9. self-assigned this
    on Jun 21, 2017
  10. Hixie commented on Jun 22, 2017

    @Hixie
    ContributorAuthor
  11. github-actions commented on Aug 17, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  12. locked as resolved and limited conversation to collaborators on Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: crashStack traces logged to the consoleengineflutter/engine related. See also e: labels.waiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions