Skip to content

Commit

Permalink
fix(macos): crashing on startup
Browse files Browse the repository at this point in the history
This issue was caused metadata_god which was incorrectly loading dynamic library
  • Loading branch information
KRTirtho committed Apr 1, 2023
1 parent 17d19e9 commit c46b428
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POCKETBASE_URL=
USERNAME=
PASSWORD=
8 changes: 4 additions & 4 deletions lib/components/library/user_local_tracks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ final localTracksProvider = FutureProvider<List<LocalTrack>>((ref) async {
}).map(
(f) async {
try {
final metadata = await MetadataGod.getMetadata(f.path);
final metadata = await MetadataGod.readMetadata(file: f.path);

final imageFile = File(join(
(await getTemporaryDirectory()).path,
"spotube",
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.writeAsBytes(
metadata?.picture?.data ?? [],
metadata.picture?.data ?? [],
mode: FileMode.writeOnly,
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:hive_flutter/hive_flutter.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:platform_ui/platform_ui.dart';
import 'package:shared_preferences/shared_preferences.dart';
Expand Down Expand Up @@ -68,6 +69,7 @@ void main(List<String> rawArgs) async {
}

WidgetsFlutterBinding.ensureInitialized();
MetadataGod.initialize();
await QueryClient.initialize(cachePrefix: "oss.krtirtho.spotube");
Hive.registerAdapter(CacheTrackAdapter());
Hive.registerAdapter(CacheTrackEngagementAdapter());
Expand Down
6 changes: 3 additions & 3 deletions lib/provider/downloader_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ class Downloader with ChangeNotifier {
final response = await get(Uri.parse(imageUri));

await MetadataGod.writeMetadata(
file.path,
Metadata(
file: file.path,
metadata: Metadata(
title: track.name,
artist: track.artists?.map((a) => a.name).join(", "),
album: track.album?.name,
Expand All @@ -123,7 +123,7 @@ class Downloader with ChangeNotifier {
fileSize: file.lengthSync(),
trackTotal: track.album?.tracks?.length,
picture: response.headers['content-type'] != null
? Image(
? Picture(
data: response.bodyBytes,
mimeType: response.headers['content-type']!,
)
Expand Down
4 changes: 0 additions & 4 deletions linux/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <audioplayers_linux/audioplayers_linux_plugin.h>
#include <catcher/catcher_plugin.h>
#include <metadata_god/metadata_god_plugin.h>
#include <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
#include <window_manager/window_manager_plugin.h>
Expand All @@ -21,9 +20,6 @@ void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) catcher_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "CatcherPlugin");
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 =
fl_plugin_registry_get_registrar_for_plugin(registry, "ScreenRetrieverPlugin");
screen_retriever_plugin_register_with_registrar(screen_retriever_registrar);
Expand Down
2 changes: 1 addition & 1 deletion linux/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_linux
catcher
metadata_god
screen_retriever
url_launcher_linux
window_manager
window_size
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
metadata_god
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down
2 changes: 0 additions & 2 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import audioplayers_darwin
import catcher
import device_info_plus
import macos_ui
import metadata_god
import package_info_plus
import path_provider_foundation
import screen_retriever
Expand All @@ -28,7 +27,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
CatcherPlugin.register(with: registry.registrar(forPlugin: "CatcherPlugin"))
DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin"))
MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin"))
MetadataGodPlugin.register(with: registry.registrar(forPlugin: "MetadataGodPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
ScreenRetrieverPlugin.register(with: registry.registrar(forPlugin: "ScreenRetrieverPlugin"))
Expand Down
10 changes: 5 additions & 5 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,10 @@ packages:
dependency: transitive
description:
name: flutter_rust_bridge
sha256: aedbf045f72c7ed778d1cfc8bff0ceae28519d258e3f477abd70ce375ae8cdda
sha256: "34f5becca2df35955b2ec5e875349028ea609a826de7aade4de80534cf876b27"
url: "https://pub.dev"
source: hosted
version: "1.62.1"
version: "1.72.1"
flutter_svg:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1002,10 +1002,10 @@ packages:
dependency: "direct main"
description:
name: metadata_god
sha256: a2a54285d363f15baa261abc16eb5f1b95397c7838a29c9c98d2a684e6fe052c
sha256: "02de939fc2dcfdc959ed34768eecc97038b6e95ebaa3415f9f7582d71a2ad047"
url: "https://pub.dev"
source: hosted
version: "0.3.2"
version: "0.4.1"
mime:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1807,5 +1807,5 @@ packages:
source: hosted
version: "1.12.3"
sdks:
dart: ">=2.19.0 <3.0.0"
dart: ">=2.19.2 <3.0.0"
flutter: ">=3.7.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ dependencies:
logger: ^1.1.0
macos_ui: ^1.9.0
marquee: ^2.2.3
metadata_god: ^0.3.2
metadata_god: ^0.4.1
mime: ^1.0.2
package_info_plus: ^3.0.2
palette_generator: ^0.3.3
Expand Down
3 changes: 0 additions & 3 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <audioplayers_windows/audioplayers_windows_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 <screen_retriever/screen_retriever_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
Expand All @@ -20,8 +19,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) {
registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin"));
CatcherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("CatcherPlugin"));
MetadataGodPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MetadataGodPluginCApi"));
PermissionHandlerWindowsPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin"));
ScreenRetrieverPluginRegisterWithRegistrar(
Expand Down
2 changes: 1 addition & 1 deletion windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
list(APPEND FLUTTER_PLUGIN_LIST
audioplayers_windows
catcher
metadata_god
permission_handler_windows
screen_retriever
url_launcher_windows
Expand All @@ -14,6 +13,7 @@ list(APPEND FLUTTER_PLUGIN_LIST
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
metadata_god
)

set(PLUGIN_BUNDLED_LIBRARIES)
Expand Down

0 comments on commit c46b428

Please sign in to comment.