mirror of
https://github.com/ente-io/ente.git
synced 2025-08-08 07:28:26 +00:00
[mob][perf] Avoid XMP extraction on main thread
This commit is contained in:
parent
c20b3cf585
commit
da7a0a60bf
@ -2,7 +2,6 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import "package:motion_photos/src/xmp_extractor.dart";
|
||||
import 'package:path/path.dart';
|
||||
import 'package:photo_manager/photo_manager.dart';
|
||||
import 'package:photos/core/configuration.dart';
|
||||
@ -185,8 +184,7 @@ class EnteFile {
|
||||
|
||||
if (mediaUploadData.isPanorama != true) {
|
||||
try {
|
||||
final xmpData = XMPExtractor()
|
||||
.extract(mediaUploadData.sourceFile!.readAsBytesSync());
|
||||
final xmpData = await getXmp(mediaUploadData.sourceFile!);
|
||||
mediaUploadData.isPanorama = checkPanoramaFromXMP(xmpData);
|
||||
} catch (_) {}
|
||||
|
||||
|
@ -160,8 +160,11 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(EnteFile file) async {
|
||||
int? motionPhotoStartingIndex;
|
||||
if (Platform.isAndroid && asset.type == AssetType.image) {
|
||||
try {
|
||||
motionPhotoStartingIndex =
|
||||
(await MotionPhotos(sourceFile.path).getMotionVideoIndex())?.start;
|
||||
motionPhotoStartingIndex = await Computer.shared().compute(
|
||||
motionVideoIndex,
|
||||
param: {'path': sourceFile.path},
|
||||
taskName: 'motionPhotoIndex',
|
||||
);
|
||||
} catch (e) {
|
||||
_logger.severe('error while detecthing motion photo start index', e);
|
||||
}
|
||||
@ -177,6 +180,11 @@ Future<MediaUploadData> _getMediaUploadDataFromAssetFile(EnteFile file) async {
|
||||
);
|
||||
}
|
||||
|
||||
Future<int?> motionVideoIndex(Map<String, dynamic> args) async {
|
||||
final String path = args['path'];
|
||||
return (await MotionPhotos(path).getMotionVideoIndex())?.start;
|
||||
}
|
||||
|
||||
Future<void> _computeZip(Map<String, dynamic> args) async {
|
||||
final String zipPath = args['zipPath'];
|
||||
final String imagePath = args['imagePath'];
|
||||
|
@ -18,8 +18,7 @@ Future<bool> checkIfPanorama(EnteFile enteFile) async {
|
||||
}
|
||||
try {
|
||||
final result = XMPExtractor().extract(file.readAsBytesSync());
|
||||
if (result["GPano:ProjectionType"] == "cylindrical" ||
|
||||
result["GPano:ProjectionType"] == "equirectangular") {
|
||||
if (checkPanoramaFromXMP(result)) {
|
||||
return true;
|
||||
}
|
||||
} catch (_) {}
|
||||
@ -30,7 +29,7 @@ Future<bool> checkIfPanorama(EnteFile enteFile) async {
|
||||
return element?.printable == "6";
|
||||
}
|
||||
|
||||
bool? checkPanoramaFromXMP(Map<String, dynamic> xmpData) {
|
||||
bool checkPanoramaFromXMP(Map<String, dynamic> xmpData) {
|
||||
if (xmpData["GPano:ProjectionType"] == "cylindrical" ||
|
||||
xmpData["GPano:ProjectionType"] == "equirectangular") {
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user