Merge pull request #3150 from fufesou/fix/memory_issue_when_decode_slow_on_flutter
try fix memory issue when decoding is too slow
This commit is contained in:
commit
2a38f6bb16
@ -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,12 +436,19 @@ 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,
|
||||||
parent.target?.ffiModel.display.height ?? 0,
|
parent.target?.ffiModel.display.height ?? 0,
|
||||||
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
|
||||||
|
decodeCount -= 1;
|
||||||
if (parent.target?.id != pid) return;
|
if (parent.target?.id != pid) return;
|
||||||
try {
|
try {
|
||||||
// my throw exception, because the listener maybe already dispose
|
// my throw exception, because the listener maybe already dispose
|
||||||
|
Loading…
x
Reference in New Issue
Block a user