Fix recursive access to SkImage in image resurrector (flutter/engine#23115)
This commit is contained in:
@@ -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 = () {
|
||||
|
||||
Reference in New Issue
Block a user