diff --git a/lib/web_ui/lib/src/engine/text/canvas_paragraph.dart b/lib/web_ui/lib/src/engine/text/canvas_paragraph.dart index 12971439f839c..df3680ad0c15e 100644 --- a/lib/web_ui/lib/src/engine/text/canvas_paragraph.dart +++ b/lib/web_ui/lib/src/engine/text/canvas_paragraph.dart @@ -260,8 +260,9 @@ class CanvasParagraph implements ui.Paragraph { @override void dispose() { - spans.clear(); - plainText = ''; + // TODO(dnfield): It should be possible to clear resources here, but would + // need refcounting done on any surfaces/pictures holding references to this + // object. _disposed = true; } @@ -270,7 +271,7 @@ class CanvasParagraph implements ui.Paragraph { if (assertionsEnabled) { return _disposed; } - throw StateError('Vertices.debugDisposed is only avialalbe when asserts are enabled.'); + throw StateError('Paragraph.debugDisposed is only avialalbe when asserts are enabled.'); } } diff --git a/lib/web_ui/test/text/canvas_paragraph_test.dart b/lib/web_ui/test/text/canvas_paragraph_test.dart index 99e464c3c8ad2..9262f0b2d7764 100644 --- a/lib/web_ui/test/text/canvas_paragraph_test.dart +++ b/lib/web_ui/test/text/canvas_paragraph_test.dart @@ -780,6 +780,27 @@ Future testMain() async { expect(paragraph.width, 30); expect(paragraph.height, 10); }); + + test('Render after dispose', () { + final ui.Paragraph paragraph = plain(ahemStyle, 'abc'); + paragraph.layout(const ui.ParagraphConstraints(width: 30.8)); + + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder); + canvas.drawParagraph(paragraph, ui.Offset.zero); + final ui.Picture picture = recorder.endRecording(); + + paragraph.dispose(); + + final ui.SceneBuilder builder = ui.SceneBuilder(); + builder.addPicture(ui.Offset.zero, picture); + final ui.Scene scene = builder.build(); + + ui.window.render(scene); + + picture.dispose(); + scene.dispose(); + }); } /// Shortcut to create a [ui.TextBox] with an optional [ui.TextDirection].