try fix memory issue when decoding is too slow
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
a313d7579d
commit
07b86bee8e
@ -415,6 +415,8 @@ class ImageModel with ChangeNotifier {
|
|||||||
|
|
||||||
String id = '';
|
String id = '';
|
||||||
|
|
||||||
|
int decodeCount = 0;
|
||||||
|
|
||||||
WeakReference<FFI> parent;
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
final List<Function(String)> _callbacksOnFirstImage = [];
|
final List<Function(String)> _callbacksOnFirstImage = [];
|
||||||
@ -434,7 +436,13 @@ class ImageModel with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (decodeCount >= 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final pid = parent.target?.id;
|
final pid = parent.target?.id;
|
||||||
|
decodeCount += 1;
|
||||||
ui.decodeImageFromPixels(
|
ui.decodeImageFromPixels(
|
||||||
rgba,
|
rgba,
|
||||||
parent.target?.ffiModel.display.width ?? 0,
|
parent.target?.ffiModel.display.width ?? 0,
|
||||||
@ -442,6 +450,7 @@ class ImageModel with ChangeNotifier {
|
|||||||
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
||||||
if (parent.target?.id != pid) return;
|
if (parent.target?.id != pid) return;
|
||||||
try {
|
try {
|
||||||
|
decodeCount -= 1;
|
||||||
// my throw exception, because the listener maybe already dispose
|
// my throw exception, because the listener maybe already dispose
|
||||||
update(image);
|
update(image);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user