From f1d978fbf76f169456a268e4a16c61437af1f47f Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Tue, 8 Jul 2025 18:46:51 +0530 Subject: [PATCH] fix: use combine for method channel communication --- .../lib/services/isolated_ffmpeg_service.dart | 18 +++++++----------- mobile/apps/photos/lib/utils/exif_util.dart | 3 ++- mobile/apps/photos/pubspec.lock | 9 +++++++++ mobile/apps/photos/pubspec.yaml | 4 ++++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/mobile/apps/photos/lib/services/isolated_ffmpeg_service.dart b/mobile/apps/photos/lib/services/isolated_ffmpeg_service.dart index 776e03994a..7502036bf9 100644 --- a/mobile/apps/photos/lib/services/isolated_ffmpeg_service.dart +++ b/mobile/apps/photos/lib/services/isolated_ffmpeg_service.dart @@ -1,8 +1,7 @@ import "dart:async"; -import "dart:io"; +import "package:combine/combine.dart"; import "package:computer/computer.dart"; -import "package:dart_ui_isolate/dart_ui_isolate.dart"; import "package:ffmpeg_kit_flutter/ffmpeg_kit.dart"; import "package:ffmpeg_kit_flutter/ffprobe_kit.dart"; import "package:ffmpeg_kit_flutter/media_information.dart"; @@ -18,14 +17,13 @@ class IsolatedFfmpegService { } static Future runFfmpeg(String command) async { - return await flutterCompute( - _ffmpegRun, - command, - ); + return await CombineWorker() + .executeWithArg(_ffmpegRun, command); } - static Future getVideoInfo(File file) async { - return flutterCompute(_getVideoProps, file.path); + static Future getVideoInfo(String file) async { + return await CombineWorker() + .executeWithArg(_getVideoProps, file); } } @@ -56,9 +54,7 @@ Future _getVideoProps(String filePath) async { } @pragma('vm:entry-point') -Future _ffmpegRun( - String value, -) async { +Future _ffmpegRun(String value) async { final session = await FFmpegKit.execute(value, true); final returnCode = (await session.getReturnCode())?.getValue(); diff --git a/mobile/apps/photos/lib/utils/exif_util.dart b/mobile/apps/photos/lib/utils/exif_util.dart index 3d2bfe29b7..9b1ae3593c 100644 --- a/mobile/apps/photos/lib/utils/exif_util.dart +++ b/mobile/apps/photos/lib/utils/exif_util.dart @@ -70,7 +70,8 @@ Future getVideoPropsAsync(File originalFile) async { try { final stopwatch = Stopwatch()..start(); - final mediaInfo = await IsolatedFfmpegService.getVideoInfo(originalFile); + final mediaInfo = + await IsolatedFfmpegService.getVideoInfo(originalFile.path); if (mediaInfo.isEmpty) { return null; } diff --git a/mobile/apps/photos/pubspec.lock b/mobile/apps/photos/pubspec.lock index cb49e18a5a..fa8c67b03c 100644 --- a/mobile/apps/photos/pubspec.lock +++ b/mobile/apps/photos/pubspec.lock @@ -324,6 +324,15 @@ packages: url: "https://pub.dev" source: hosted version: "1.19.1" + combine: + dependency: "direct main" + description: + path: "." + ref: "feat_version_3.32.0" + resolved-ref: "49a02bc7b2d3636f7c3dba294371959f9f60a513" + url: "https://github.com/mobaink/combine.git" + source: git + version: "0.5.8" computer: dependency: "direct main" description: diff --git a/mobile/apps/photos/pubspec.yaml b/mobile/apps/photos/pubspec.yaml index c64514350d..de62ace4f5 100644 --- a/mobile/apps/photos/pubspec.yaml +++ b/mobile/apps/photos/pubspec.yaml @@ -36,6 +36,10 @@ dependencies: url: https://github.com/ente-io/chewie.git ref: mybranched collection: #dart + combine: + git: + url: https://github.com/mobaink/combine.git + ref: feat_version_3.32.0 computer: # logged task name in verbose in fork git: "https://github.com/ente-io/computer.git" connectivity_plus: ^6.0.2