mirror of
https://github.com/KRTirtho/spotube.git
synced 2026-08-05 19:59:51 +00:00
fix: don't abort startup when launched headless (no Activity)
When the app is started in the background without an Activity — e.g. by Android Auto's MediaBrowserService or a media-button intent — FlutterDisplayMode.setHighRefreshRate() throws PlatformException(noActivity). Because it was awaited unguarded in main(), the exception aborted bootstrap before runApp(), so the audio handler was never registered and media browsers (Android Auto) hung indefinitely on a spinner. Wrap the non-essential high-refresh-rate call in try/catch so headless startup completes and the audio service registers.
This commit is contained in:
parent
69a310c78f
commit
f9e1794860
@ -82,7 +82,16 @@ Future<void> main(List<String> rawArgs) async {
|
|||||||
|
|
||||||
// force High Refresh Rate on some Android devices (like One Plus)
|
// force High Refresh Rate on some Android devices (like One Plus)
|
||||||
if (kIsAndroid) {
|
if (kIsAndroid) {
|
||||||
await FlutterDisplayMode.setHighRefreshRate();
|
try {
|
||||||
|
await FlutterDisplayMode.setHighRefreshRate();
|
||||||
|
} catch (e, stack) {
|
||||||
|
// When the app is cold-started headless (e.g. by Android Auto's
|
||||||
|
// MediaBrowserService) there is no attached Activity, so this throws
|
||||||
|
// PlatformException(noActivity). Refresh-rate tuning is non-essential
|
||||||
|
// and must not abort bootstrap — otherwise runApp() never runs and the
|
||||||
|
// audio handler is never registered, hanging media browsers forever.
|
||||||
|
AppLogger.reportError(e, stack);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (kIsAndroid || kIsDesktop) {
|
if (kIsAndroid || kIsDesktop) {
|
||||||
await NewPipeExtractor.init();
|
await NewPipeExtractor.init();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user