Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix: temp commit, to revert

Prateek Sunal8b4f03b256dd
diff --git a/mobile/lib/services/isolated_ffmpeg_service.dart b/mobile/lib/services/isolated_ffmpeg_service.dart
index 8637424b32..84ce43304b 100644
--- a/mobile/lib/services/isolated_ffmpeg_service.dart
+++ b/mobile/lib/services/isolated_ffmpeg_service.dart
@@ -1,6 +1,10 @@
+import "dart:isolate" show Isolate;
+
import "package:computer/computer.dart";
import "package:ffmpeg_kit_flutter/ffmpeg_kit.dart";
import "package:ffmpeg_kit_flutter/ffmpeg_session.dart";
+import "package:flutter/services.dart"
+ show RootIsolateToken, BackgroundIsolateBinaryMessenger;
import "package:logging/logging.dart";
class IsolatedFfmpegService {
@@ -12,22 +16,30 @@ class IsolatedFfmpegService {
await _computer?.turnOn(workersCount: 1);
}
- static Future<FFmpegSession> runFfmpeg(String command) async {
- if (_computer == null) {
- await init();
- }
- return await _computer!.compute<Map, FFmpegSession>(
+ static Future<dynamic> runFfmpeg(String command) async {
+ // if (_computer == null) {
+ // await init();
+ // }
+
+ RootIsolateToken rootIsolateToken = RootIsolateToken.instance!;
+ return await Isolate.spawn<(String, RootIsolateToken)>(
_ffmpegRun,
- param: {'command': command},
- ).onError((error, st) {
- _logger.warning("Error: $error");
- throw error!;
- });
+ (command, rootIsolateToken),
+ );
+ // return await _computer!.compute<Map, FFmpegSession>(
+ // _ffmpegRun,
+ // param: {'command': command},
+ // ).onError((error, st) {
+ // _logger.warning("Error: $error");
+ // throw error!;
+ // });
}
- static Future<FFmpegSession> _ffmpegRun(Map args) async {
- final command = args['command'] as String;
- final session = await FFmpegKit.execute(command);
+ static Future<FFmpegSession> _ffmpegRun(
+ (String, RootIsolateToken) value,
+ ) async {
+ BackgroundIsolateBinaryMessenger.ensureInitialized(value.$2);
+ final session = await FFmpegKit.execute(value.$1);
return session;
}
}
diff --git a/mobile/lib/services/video_preview_service.dart b/mobile/lib/services/video_preview_service.dart
index bfcce8c381..dbf789fd80 100644
--- a/mobile/lib/services/video_preview_service.dart
+++ b/mobile/lib/services/video_preview_service.dart
@@ -124,8 +124,7 @@ class VideoPreviewService {
EnteFile enteFile, [
bool forceUpload = false,
]) async {
- if (!isVideoStreamingEnabled ||
- !computeController.requestCompute(stream: true)) {
+ if (!isVideoStreamingEnabled) {
_logger.info(
"Pause preview due to disabledSteaming($isVideoStreamingEnabled) or computeController permission)",
);
@@ -285,7 +284,7 @@ class VideoPreviewService {
);
}
- final returnCode = await session.getReturnCode();
+ final returnCode = await session?.getReturnCode();
String? objectId;
int? objectSize;
@@ -345,7 +344,7 @@ class VideoPreviewService {
_logger.warning("FFmpeg command cancelled");
error = "FFmpeg command cancelled";
} else {
- final output = await session.getOutput();
+ final output = await session?.getOutput();
_logger.shout(
"FFmpeg command failed with return code $returnCode",
output ?? "Error not found",
@@ -744,12 +743,12 @@ class VideoPreviewService {
}
final int size = enteFile.fileSize!;
final int duration = enteFile.duration!;
- if (size >= 500 * 1024 * 1024 || duration > 60) {
- _logger.info(
- "Skip Preview due to size: $size or duration: $duration",
- );
- return (null, true, null);
- }
+ // if (size >= 500 * 1024 * 1024 || duration > 60) {
+ // _logger.info(
+ // "Skip Preview due to size: $size or duration: $duration",
+ // );
+ // return (null, true, null);
+ // }
FFProbeProps? props;
File? file;
bool skipFile = false;
@@ -862,11 +861,11 @@ class VideoPreviewService {
void queueFiles() {
Future.delayed(const Duration(seconds: 5), () {
- if (!_hasQueuedFile && computeController.requestCompute(stream: true)) {
- _putFilesForPreviewCreation(true).catchError((_) {
- _hasQueuedFile = false;
- });
- }
+ // if (!_hasQueuedFile && computeController.requestCompute(stream: true)) {
+ _putFilesForPreviewCreation(true).catchError((_) {
+ _hasQueuedFile = false;
+ });
+ // }
});
}
}