fix(macos): crashing on startup

This issue was caused metadata_god which was incorrectly loading dynamic library
This commit is contained in:
Kingkor Roy Tirtho 2023-04-01 13:00:18 +06:00
parent 17d19e9584
commit c46b4284b1
11 changed files with 20 additions and 24 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
POCKETBASE_URL=
USERNAME=
PASSWORD=

View File

@ -77,18 +77,18 @@ final localTracksProvider = FutureProvider<List<LocalTrack>>((ref) async {
}).map( }).map(
(f) async { (f) async {
try { try {
final metadata = await MetadataGod.getMetadata(f.path); final metadata = await MetadataGod.readMetadata(file: f.path);
final imageFile = File(join( final imageFile = File(join(
(await getTemporaryDirectory()).path, (await getTemporaryDirectory()).path,
"spotube", "spotube",
basenameWithoutExtension(f.path) + basenameWithoutExtension(f.path) +
imgMimeToExt[metadata?.picture?.mimeType ?? "image/jpeg"]!, imgMimeToExt[metadata.picture?.mimeType ?? "image/jpeg"]!,
)); ));
if (!await imageFile.exists() && metadata?.picture != null) { if (!await imageFile.exists() && metadata.picture != null) {
await imageFile.create(recursive: true); await imageFile.create(recursive: true);
await imageFile.writeAsBytes( await imageFile.writeAsBytes(
metadata?.picture?.data ?? [], metadata.picture?.data ?? [],
mode: FileMode.writeOnly, mode: FileMode.writeOnly,
); );
} }

View File

@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hive_flutter/hive_flutter.dart'; import 'package:hive_flutter/hive_flutter.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:metadata_god/metadata_god.dart';
import 'package:package_info_plus/package_info_plus.dart'; import 'package:package_info_plus/package_info_plus.dart';
import 'package:platform_ui/platform_ui.dart'; import 'package:platform_ui/platform_ui.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
@ -68,6 +69,7 @@ void main(List<String> rawArgs) async {
} }
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
MetadataGod.initialize();
await QueryClient.initialize(cachePrefix: "oss.krtirtho.spotube"); await QueryClient.initialize(cachePrefix: "oss.krtirtho.spotube");
Hive.registerAdapter(CacheTrackAdapter()); Hive.registerAdapter(CacheTrackAdapter());
Hive.registerAdapter(CacheTrackEngagementAdapter()); Hive.registerAdapter(CacheTrackEngagementAdapter());

View File

@ -108,8 +108,8 @@ class Downloader with ChangeNotifier {
final response = await get(Uri.parse(imageUri)); final response = await get(Uri.parse(imageUri));
await MetadataGod.writeMetadata( await MetadataGod.writeMetadata(
file.path, file: file.path,
Metadata( metadata: Metadata(
title: track.name, title: track.name,
artist: track.artists?.map((a) => a.name).join(", "), artist: track.artists?.map((a) => a.name).join(", "),
album: track.album?.name, album: track.album?.name,
@ -123,7 +123,7 @@ class Downloader with ChangeNotifier {
fileSize: file.lengthSync(), fileSize: file.lengthSync(),
trackTotal: track.album?.tracks?.length, trackTotal: track.album?.tracks?.length,
picture: response.headers['content-type'] != null picture: response.headers['content-type'] != null
? Image( ? Picture(
data: response.bodyBytes, data: response.bodyBytes,
mimeType: response.headers['content-type']!, mimeType: response.headers['content-type']!,
) )

View File

@ -8,7 +8,6 @@
#include <audioplayers_linux/audioplayers_linux_plugin.h> #include <audioplayers_linux/audioplayers_linux_plugin.h>
#include <catcher/catcher_plugin.h> #include <catcher/catcher_plugin.h>
#include <metadata_god/metadata_god_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h> #include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h> #include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h> #include <window_manager/window_manager_plugin.h>
@ -21,9 +20,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) catcher_registrar = g_autoptr(FlPluginRegistrar) catcher_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin");
catcher_plugin_register_with_registrar(catcher_registrar); catcher_plugin_register_with_registrar(catcher_registrar);
g_autoptr(FlPluginRegistrar) metadata_god_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MetadataGodPlugin");
metadata_god_plugin_register_with_registrar(metadata_god_registrar);
g_autoptr(FlPluginRegistrar) screen_retriever_registrar = g_autoptr(FlPluginRegistrar) screen_retriever_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin"); fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar); screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);

View File

@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux audioplayers_linux
catcher catcher
metadata_god
screen_retriever screen_retriever
url_launcher_linux url_launcher_linux
window_manager window_manager
@ -13,6 +12,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST
metadata_god
) )
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)

View File

@ -11,7 +11,6 @@ import audioplayers_darwin
import catcher import catcher
import device_info_plus import device_info_plus
import macos_ui import macos_ui
import metadata_god
import package_info_plus import package_info_plus
import path_provider_foundation import path_provider_foundation
import screen_retriever import screen_retriever
@ -28,7 +27,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin")) CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin")) MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
MetadataGodPlugin.register(with: registry.registrar(forPlugin: "MetadataGodPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin")) ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))

View File

@ -704,10 +704,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: flutter_rust_bridge name: flutter_rust_bridge
sha256: aedbf045f72c7ed778d1cfc8bff0ceae28519d258e3f477abd70ce375ae8cdda sha256: "34f5becca2df35955b2ec5e875349028ea609a826de7aade4de80534cf876b27"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.62.1" version: "1.72.1"
flutter_svg: flutter_svg:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1002,10 +1002,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: metadata_god name: metadata_god
sha256: a2a54285d363f15baa261abc16eb5f1b95397c7838a29c9c98d2a684e6fe052c sha256: "02de939fc2dcfdc959ed34768eecc97038b6e95ebaa3415f9f7582d71a2ad047"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.3.2" version: "0.4.1"
mime: mime:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1807,5 +1807,5 @@ packages:
source: hosted source: hosted
version: "1.12.3" version: "1.12.3"
sdks: sdks:
dart: ">=2.19.0 <3.0.0" dart: ">=2.19.2 <3.0.0"
flutter: ">=3.7.0" flutter: ">=3.7.0"

View File

@ -52,7 +52,7 @@ dependencies:
logger: ^1.1.0 logger: ^1.1.0
macos_ui: ^1.9.0 macos_ui: ^1.9.0
marquee: ^2.2.3 marquee: ^2.2.3
metadata_god: ^0.3.2 metadata_god: ^0.4.1
mime: ^1.0.2 mime: ^1.0.2
package_info_plus: ^3.0.2 package_info_plus: ^3.0.2
palette_generator: ^0.3.3 palette_generator: ^0.3.3

View File

@ -8,7 +8,6 @@
#include <audioplayers_windows/audioplayers_windows_plugin.h> #include <audioplayers_windows/audioplayers_windows_plugin.h>
#include <catcher/catcher_plugin.h> #include <catcher/catcher_plugin.h>
#include <metadata_god/metadata_god_plugin_c_api.h>
#include <permission_handler_windows/permission_handler_windows_plugin.h> #include <permission_handler_windows/permission_handler_windows_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h> #include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h> #include <url_launcher_windows/url_launcher_windows.h>
@ -20,8 +19,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
CatcherPluginRegisterWithRegistrar( CatcherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("CatcherPlugin")); registry->GetRegistrarForPlugin("CatcherPlugin"));
MetadataGodPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MetadataGodPluginCApi"));
PermissionHandlerWindowsPluginRegisterWithRegistrar( PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
ScreenRetrieverPluginRegisterWithRegistrar( ScreenRetrieverPluginRegisterWithRegistrar(

View File

@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows audioplayers_windows
catcher catcher
metadata_god
permission_handler_windows permission_handler_windows
screen_retriever screen_retriever
url_launcher_windows url_launcher_windows
@ -14,6 +13,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
) )
list(APPEND FLUTTER_FFI_PLUGIN_LIST list(APPEND FLUTTER_FFI_PLUGIN_LIST
metadata_god
) )
set(PLUGIN_BUNDLED_LIBRARIES) set(PLUGIN_BUNDLED_LIBRARIES)