未验证 提交 fd6b409f 编写于 作者: Y Yegor 提交者: GitHub

Fix recursive access to SkImage in image resurrector (#23115)

上级 eb472cc4
......@@ -179,11 +179,13 @@ class CkImage implements ui.Image, StackTraceDebugger {
colorType: canvasKit.ColorType.RGBA_8888,
colorSpace: SkColorSpaceSRGB,
);
final int originalWidth = skImage.width();
final int originalHeight = skImage.height();
box = SkiaObjectBox<CkImage, SkImage>.resurrectable(this, skImage, () {
return canvasKit.MakeImage(
originalBytes.buffer.asUint8List(),
width,
height,
originalWidth,
originalHeight,
canvasKit.AlphaType.Premul,
canvasKit.ColorType.RGBA_8888,
SkColorSpaceSRGB,
......
......@@ -113,6 +113,26 @@ void testMain() {
testCollector.collectNow();
});
// Regression test for https://github.com/flutter/flutter/issues/72469
test('CkImage can be resurrected', () {
browserSupportsFinalizationRegistry = false;
final SkImage skImage =
canvasKit.MakeAnimatedImageFromEncoded(kTransparentImage)
.getCurrentFrame();
final CkImage image = CkImage(skImage);
expect(image.box.rawSkiaObject, isNotNull);
// Pretend that the image is temporarily deleted.
image.box.delete();
image.box.didDelete();
expect(image.box.rawSkiaObject, isNull);
// Attempting to access the skia object here would previously throw
// "Stack Overflow" in Safari.
expect(image.box.skiaObject, isNotNull);
testCollector.collectNow();
});
test('skiaInstantiateWebImageCodec loads an image from the network',
() async {
httpRequestFactory = () {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册