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:
RustDesk 2023-02-10 18:40:00 +08:00 committed by GitHub
commit 2a38f6bb16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -415,6 +415,8 @@ class ImageModel with ChangeNotifier {
String id = '';
int decodeCount = 0;
WeakReference<FFI> parent;
final List<Function(String)> _callbacksOnFirstImage = [];
@ -434,12 +436,19 @@ class ImageModel with ChangeNotifier {
}
}
}
if (decodeCount >= 1) {
return;
}
final pid = parent.target?.id;
decodeCount += 1;
ui.decodeImageFromPixels(
rgba,
parent.target?.ffiModel.display.width ?? 0,
parent.target?.ffiModel.display.height ?? 0,
isWeb ? ui.PixelFormat.rgba8888 : ui.PixelFormat.bgra8888, (image) {
decodeCount -= 1;
if (parent.target?.id != pid) return;
try {
// my throw exception, because the listener maybe already dispose