spotube icon indicating copy to clipboard operation
spotube copied to clipboard

Allways run in background even if not used resulting in high battery usage

Open Guarmanda opened this issue 8 months ago • 4 comments

Is there an existing issue for this? (Please read the description)

  • [x] I have searched the existing issues

Current Behavior

The app allways run in background, like 100% of the time, and is the app that spend the most battery on my phone, before instagram, snapchat, reddit and any other app I use. When I sleep of don't use my phone, or even if I use it but a little, the app is like 33% of my battery usage, according to battery settings. This is really anoying, because despite some titles are totally wrong, the app is really great^^ (some titles don't play with the right artist, or play a random video that isn't a song at all but that's another issue)

Expected Behavior

The app stops running in background after some minutes with the music paused, maybe?

Steps to reproduce

  1. watch battery usage
  2. cry
  3. create a github issue

Logs

Logs
/src/client.dart:134)
<asynchronous suspension>
#1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:93)
<asynchronous suspension>
#2      SpotifyApiBase._getImpl.<anonymous closure> (package:spotify/src/spotify_base.dart:211)
<asynchronous suspension>
#3      SpotifyApiBase._requestWrapper (package:spotify/src/spotify_base.dart:247)
<asynchronous suspension>
#4      SpotifyApiBase._getImpl (package:spotify/src/spotify_base.dart:210)
<asynchronous suspension>
#5      Me.get (package:spotify/src/endpoints/me.dart:22)
<asynchronous suspension>
#6      SpotifyApiWrapper.invoke (package:spotube/provider/spotify/spotify.dart:96)
<asynchronous suspension>
#7      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-01 17:30:55.527980]---------------------
OAuth authorization error (invalid_token): The access token expired.
#0      Client.send (package:oauth2/src/client.dart:134)
<asynchronous suspension>
#1      BaseClient._sendUnstreamed (package:http/src/base_client.dart:93)
<asynchronous suspension>
#2      SpotifyApiBase._getImpl.<anonymous closure> (package:spotify/src/spotify_base.dart:211)
<asynchronous suspension>
#3      SpotifyApiBase._requestWrapper (package:spotify/src/spotify_base.dart:247)
<asynchronous suspension>
#4      SpotifyApiBase._getImpl (package:spotify/src/spotify_base.dart:210)
<asynchronous suspension>
#5      Pages.getPage (package:spotify/src/endpoints/endpoint_paging.dart:253)
<asynchronous suspension>
#6      SpotifyApiWrapper.invoke (package:spotube/provider/spotify/spotify.dart:96)
<asynchronous suspension>
#7      AlbumReleasesNotifier.fetch (package:spotube/provider/spotify/album/releases.dart:35)
<asynchronous suspension>
#8      AlbumReleasesNotifier.build (package:spotube/provider/spotify/album/releases.dart:50)
<asynchronous suspension>
#9      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-01 17:30:55.543881]---------------------
DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

#0      DioMixin.fetch (package:dio/src/dio_mixin.dart:520)
<asynchronous suspension>
#1      CustomSpotifyEndpoints.getView (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:80)
<asynchronous suspension>
#2      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-01 17:30:55.620130]---------------------
DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

#0      DioMixin.fetch (package:dio/src/dio_mixin.dart:520)
<asynchronous suspension>
#1      CustomSpotifyEndpoints.getFriendActivity (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:113)
<asynchronous suspension>
#2      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-01 17:30:57.140245]---------------------
NoSuchMethodError: The method '[]' was called on null.
Receiver: null
Tried calling: []("__typename")
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38)
#1      _objectNoSuchMethod (dart:core-patch/object_patch.dart:88)
#2      transformSectionItemTypeJsonMap (package:spotube/models/spotify/home_feed.dart:174)
#3      transformSectionItemJsonMap.<anonymous closure> (package:spotube/models/spotify/home_feed.dart:220)
#4      MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#5      ListIterator.moveNext (dart:_internal/iterable.dart:371)
#6      WhereIterator.moveNext (dart:_internal/iterable.dart:467)
#7      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:203)
#8      new _GrowableList.of (dart:core-patch/growable_array.dart:152)
#9      new List.of (dart:core-patch/array_patch.dart:40)
#10     Iterable.toList (dart:core/iterable.dart:499)
#11     transformSectionItemJsonMap (package:spotube/models/spotify/home_feed.dart:229)
#12     transformHomeFeedJsonMap.<anonymous closure> (package:spotube/models/spotify/home_feed.dart:241)
#13     MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#14     ListIterator.moveNext (dart:_internal/iterable.dart:371)
#15     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:190)
#16     new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#17     new List.of (dart:core-patch/array_patch.dart:40)
#18     ListIterable.toList (dart:_internal/iterable.dart:224)
#19     transformHomeFeedJsonMap (package:spotube/models/spotify/home_feed.dart:244)
#20     CustomSpotifyEndpoints.getHomeFeed (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:164)
<asynchronous suspension>
#21     FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-01 17:53:39.955861]---------------------
VideoUnplayableException: Video 'cJ5VHjeuO3k' is unplayable.
Streams are not available for this video.
In most cases, this error indicates that there are 
some restrictions in place that prevent watching this video.
Reason: This video is not available
#0      StreamClient.getManifest (package:youtube_explode_dart/src/videos/streams/stream_client.dart:117)
<asynchronous suspension>
#1      YoutubeSourcedTrack.toSiblingType (package:spotube/services/sourced_track/sources/youtube.dart:164)
<asynchronous suspension>
#2      YoutubeSourcedTrack.fetchSiblings (package:spotube/services/sourced_track/sources/youtube.dart:252)
<asynchronous suspension>
#3      YoutubeSourcedTrack.fetchFromTrack (package:spotube/services/sourced_track/sources/youtube.dart:81)
<asynchronous suspension>
#4      SourcedTrack.fetchFromTrack (package:spotube/services/sourced_track/sourced_track.dart:113)
<asynchronous suspension>
#5      SourcedTrackNotifier.build (package:spotube/provider/server/sourced_track.dart:27)
<asynchronous suspension>
#6      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-02 09:12:44.688107]---------------------
[MediaKitError] 
Option af: dynaudnorm doesn't exist.
#0      new CustomPlayer.<anonymous closure> (package:spotube/services/audio_player/custom_player.dart:51)
#1      _rootRunUnary (dart:async/zone.dart:1538)
#2      _CustomZone.runUnary (dart:async/zone.dart:1429)
#3      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1329)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381)
#5      _DelayedData.perform (dart:async/stream_impl.dart:573)
#6      _PendingEvents.handleNext (dart:async/stream_impl.dart:678)
#7      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:649)
#8      _rootRun (dart:async/zone.dart:1517)
#9      _CustomZone.run (dart:async/zone.dart:1422)
#10     _CustomZone.runGuarded (dart:async/zone.dart:1321)
#11     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1362)
#12     _rootRun (dart:async/zone.dart:1525)
#13     _CustomZone.run (dart:async/zone.dart:1422)
#14     _CustomZone.runGuarded (dart:async/zone.dart:1321)
#15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1362)
#16     _microtaskLoop (dart:async/schedule_microtask.dart:40)
#17     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)

----------------------------------------
[2025-04-02 09:12:45.519617]---------------------
DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

#0      DioMixin.fetch (package:dio/src/dio_mixin.dart:520)
<asynchronous suspension>
#1      CustomSpotifyEndpoints.getView (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:80)
<asynchronous suspension>
#2      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
-----------------------
potify/playlist/featured.dart:43)
<asynchronous suspension>
#9      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-02 09:12:45.519891]---------------------
DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

#0      DioMixin.fetch (package:dio/src/dio_mixin.dart:520)
<asynchronous suspension>
#1      CustomSpotifyEndpoints.getHomeFeed (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:131)
<asynchronous suspension>
#2      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-02 09:12:45.603868]---------------------
DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.
The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled"
Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code.

#0      DioMixin.fetch (package:dio/src/dio_mixin.dart:520)
<asynchronous suspension>
#1      CustomSpotifyEndpoints.getFriendActivity (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:113)
<asynchronous suspension>
#2      FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-02 09:12:47.211241]---------------------
NoSuchMethodError: The method '[]' was called on null.
Receiver: null
Tried calling: []("__typename")
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38)
#1      _objectNoSuchMethod (dart:core-patch/object_patch.dart:88)
#2      transformSectionItemTypeJsonMap (package:spotube/models/spotify/home_feed.dart:174)
#3      transformSectionItemJsonMap.<anonymous closure> (package:spotube/models/spotify/home_feed.dart:220)
#4      MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#5      ListIterator.moveNext (dart:_internal/iterable.dart:371)
#6      WhereIterator.moveNext (dart:_internal/iterable.dart:467)
#7      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:203)
#8      new _GrowableList.of (dart:core-patch/growable_array.dart:152)
#9      new List.of (dart:core-patch/array_patch.dart:40)
#10     Iterable.toList (dart:core/iterable.dart:499)
#11     transformSectionItemJsonMap (package:spotube/models/spotify/home_feed.dart:229)
#12     transformHomeFeedJsonMap.<anonymous closure> (package:spotube/models/spotify/home_feed.dart:241)
#13     MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#14     ListIterator.moveNext (dart:_internal/iterable.dart:371)
#15     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:190)
#16     new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#17     new List.of (dart:core-patch/array_patch.dart:40)
#18     ListIterable.toList (dart:_internal/iterable.dart:224)
#19     transformHomeFeedJsonMap (package:spotube/models/spotify/home_feed.dart:244)
#20     CustomSpotifyEndpoints.getHomeFeed (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:164)
<asynchronous suspension>
#21     FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-02 15:32:27.653152]---------------------
Option af: dynaudnorm doesn't exist.
#0      new AudioPlayerInterface.<anonymous closure> (package:spotube/services/audio_player/audio_player.dart:93)
#1      _rootRunUnary (dart:async/zone.dart:1538)
#2      _CustomZone.runUnary (dart:async/zone.dart:1429)
#3      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1329)
#4      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:381)
#5      _DelayedData.perform (dart:async/stream_impl.dart:573)
#6      _PendingEvents.handleNext (dart:async/stream_impl.dart:678)
#7      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:649)
#8      _rootRun (dart:async/zone.dart:1517)
#9      _CustomZone.run (dart:async/zone.dart:1422)
#10     _CustomZone.runGuarded (dart:async/zone.dart:1321)
#11     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1362)
#12     _rootRun (dart:async/zone.dart:1525)
#13     _CustomZone.run (dart:async/zone.dart:1422)
#14     _CustomZone.runGuarded (dart:async/zone.dart:1321)
#15     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1362)
#16     _microtaskLoop (dart:async/schedule_microtask.dart:40)
#17     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49)

----------------------------------------
---------
[2025-04-02 15:32:28.991931]---------------------
NoSuchMethodError: The method '[]' was called on null.
Receiver: null
Tried calling: []("__typename")
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38)
#1      _objectNoSuchMethod (dart:core-patch/object_patch.dart:88)
#2      transformSectionItemTypeJsonMap (package:spotube/models/spotify/home_feed.dart:174)
#3      transformSectionItemJsonMap.<anonymous closure> (package:spotube/models/spotify/home_feed.dart:220)
#4      MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#5      ListIterator.moveNext (dart:_internal/iterable.dart:371)
#6      WhereIterator.moveNext (dart:_internal/iterable.dart:467)
#7      new _GrowableList._ofOther (dart:core-patch/growable_array.dart:203)
#8      new _GrowableList.of (dart:core-patch/growable_array.dart:152)
#9      new List.of (dart:core-patch/array_patch.dart:40)
#10     Iterable.toList (dart:core/iterable.dart:499)
#11     transformSectionItemJsonMap (package:spotube/models/spotify/home_feed.dart:229)
#12     transformHomeFeedJsonMap.<anonymous closure> (package:spotube/models/spotify/home_feed.dart:241)
#13     MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#14     ListIterator.moveNext (dart:_internal/iterable.dart:371)
#15     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:190)
#16     new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#17     new List.of (dart:core-patch/array_patch.dart:40)
#18     ListIterable.toList (dart:_internal/iterable.dart:224)
#19     transformHomeFeedJsonMap (package:spotube/models/spotify/home_feed.dart:244)
#20     CustomSpotifyEndpoints.getHomeFeed (package:spotube/services/custom_spotify_endpoints/spotify_endpoints.dart:164)
<asynchronous suspension>
#21     FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------
[2025-04-02 15:32:31.848810]---------------------
type 'Null' is not a subtype of type 'String' in type cast
#0      _$$InvidiousMonitorImplFromJson (package:invidious/src/models/model.g.dart:477)
#1      new _$InvidiousMonitorImpl.fromJson (package:invidious/src/models/model.freezed.dart:5728)
#2      _$InvidiousMonitorFromJson (package:invidious/src/models/model.freezed.dart:5309)
#3      new InvidiousMonitor.fromJson (package:invidious/src/models/responses/instance.dart:128)
#4      _$$InvidiousInstanceDetailsImplFromJson (package:invidious/src/models/model.g.dart:361)
#5      new _$InvidiousInstanceDetailsImpl.fromJson (package:invidious/src/models/model.freezed.dart:4092)
#6      _$InvidiousInstanceDetailsFromJson (package:invidious/src/models/model.freezed.dart:3858)
#7      new InvidiousInstanceDetails.fromJson (package:invidious/src/models/responses/instance.dart:28)
#8      _$$InvidiousInstanceResponseImplFromJson (package:invidious/src/models/model.g.dart:336)
#9      new _$InvidiousInstanceResponseImpl.fromJson (package:invidious/src/models/model.freezed.dart:3792)
#10     _$InvidiousInstanceResponseFromJson (package:invidious/src/models/model.freezed.dart:3668)
#11     new InvidiousInstanceResponse.fromJson (package:invidious/src/models/responses/instance.dart:11)
#12     InstancesEndpoint.instances.<anonymous closure> (package:invidious/src/endpoints/instances.dart:13)
#13     MappedIterable.elementAt (dart:_internal/iterable.dart:402)
#14     ListIterator.moveNext (dart:_internal/iterable.dart:371)
#15     new _GrowableList._ofEfficientLengthIterable (dart:core-patch/growable_array.dart:190)
#16     new _GrowableList.of (dart:core-patch/growable_array.dart:150)
#17     new List.of (dart:core-patch/array_patch.dart:40)
#18     ListIterable.toList (dart:_internal/iterable.dart:224)
#19     InstancesEndpoint.instances (package:invidious/src/endpoints/instances.dart:17)
<asynchronous suspension>
#20     invidiousInstancesProvider.<anonymous closure> (package:spotube/provider/audio_player/sources/invidious_instances_provider.dart:7)
<asynchronous suspension>
#21     FutureHandlerProviderElementMixin.handleFuture.<anonymous closure>.<anonymous closure> (package:riverpod/src/async_notifier/base.dart:355)
<asynchronous suspension>

----------------------------------------

Operating System

Android 15, LineageOS

Spotube version

4.0.1-nightly

Installation source

Website (spotube.krtirtho.dev)

Additional information

No response

Self grab

  • [ ] I'm ready to work on this issue!

Guarmanda avatar Apr 02 '25 13:04 Guarmanda

I noticed the same with the nightly version, but have not encountered it with the stable release. The nightly remained active in the background even when it's not playing and even when removing it from the recent list.

drake7707 avatar Apr 08 '25 08:04 drake7707

Image

Guarmanda avatar Apr 16 '25 17:04 Guarmanda

Same here. Linux mint LMDE 6

clmaes avatar Apr 18 '25 10:04 clmaes

Same here on Android 15, GrapheneOS.

adminelix avatar Apr 18 '25 22:04 adminelix

Same on android 16, from 15 to 20% usage daily. I haven't opened the app in weeks.

luispabon avatar Aug 10 '25 08:08 luispabon