Skip to content

[Bug]: Egregious levels of battery drain on 5.0.3 #1880

Closed
@isles1217

Description

@isles1217

What happened?

Since upgrading to OneSignal 5.x.x, we've been noticing egregious levels of battery drain that disappear after reverting back to 4.x.x. Our users have started to notice as well, and we're starting to get slammed with negative reviews on the Play Store because of this. From my observations, I'm seeing up to 20% of my device's battery getting drained AN HOUR, even with my screen off and my app backgrounded. What is going on in this new version?

Steps to reproduce?

1. Install an app running OneSignal 5.0.3
2. Measure battery usage with screen on, off, app in the foreground/background
3. Then pause/uninstall the app. Measure the battery usage.
4. Install the same app running OneSignal 4.x.x. Use the device similary, and measure the battery usage. 

You'll likely see 2-5x increase of battery consumption on 5.x.x

What did you expect to happen?

OneSignal should not eat up my device's battery

OneSignal Android SDK version

5.0.3

Android version

13

Specific Android models

* Issue occurs all devices I've tested (running Android 13, 14)
* Devices the issue was reproduced on: Google Pixel 7, 7a, 5a.

Relevant log output

--------- beginning of main
11:22:31.255  D  [main] ApplicationService.onActivityStopped(2,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:06.007  D  [main] ApplicationService.onActivityCreated(1,APP_OPEN): [com.example.application]Activity@8831df3
11:24:06.019  D  [main] ApplicationService.onActivityStarted(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:06.084  D  [main] ApplicationService.onActivityResumed(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:06.161  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:06.567  D  [main] ApplicationService.onActivityDestroyed(1,APP_OPEN): [com.example.application]Activity@8831df3
11:24:09.129  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:09.215  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:09.344  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:09.401  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:18.323  D  [main] ApplicationService.onActivityPaused(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:18.881  D  [main] ApplicationService.onActivityStopped(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:18.881  D  [main] ApplicationService: current activity=null
11:24:18.881  D  [main] ApplicationService.handleLostFocus: application is now out of focus
11:24:18.882  D  [main] LocationController scheduleUpdate not possible, location shared not enabled
11:24:18.882  D  [main] OSBackgroundSync scheduleSyncServiceAsJob:atTime: 30000
11:24:18.884  I  [main] OSBackgroundSync scheduleSyncServiceAsJob:result: 1
11:24:18.884  D  [main] SessionService.onUnfocused()
11:24:26.569  D  [main] ApplicationService.onActivityCreated(0,APP_CLOSE): [com.example.application]Activity@e2efc5d
11:24:26.576  D  [main] ApplicationService.onActivityStarted(0,APP_CLOSE): [com.example.application]Activity@6e1ba65
11:24:26.576  D  [main] ApplicationService: current activity=[com.example.application]Activity@6e1ba65
11:24:26.576  D  [main] ApplicationService.handleFocus: application is now in focus, nextResumeIsFirstActivity=false
11:24:26.576  D  [main] BackgroundManager cancel background sync
11:24:26.577  D  [main] SessionService.onFocus()
11:24:26.577  D  [main] InfluenceManager.attemptSessionUpgrade(entryAction: APP_OPEN, directId: null)
11:24:26.577  D  [main] InfluenceManager.attemptSessionUpgrade: try UNATTRIBUTED to INDIRECT upgrade
11:24:26.577  D  [main] ChannelTracker.getLastReceivedIds: lastChannelObjectReceived: []
11:24:26.577  D  [main] InfluenceManager.attemptSessionUpgrade: Trackers after update attempt: [ChannelTracker{tag=notification_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}, ChannelTracker{tag=iam_id, influenceType=INDIRECT, indirectIds=["c0d845f1-00e3-442c-9394-7223688d4d19"], directId=null}]
11:24:26.631  D  [main] ApplicationService.onActivityResumed(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:26.697  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:27.119  D  [main] ApplicationService.onActivityDestroyed(1,APP_OPEN): [com.example.application]Activity@e2efc5d
11:24:29.032  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:29.066  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:29.091  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:29.154  D  [main] InAppMessagesManager.addTrigger(key: home screen active, value: true)
11:24:30.180  D  [main] ApplicationService.onActivityPaused(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:30.219  D  [main] ApplicationService.onActivityStopped(1,APP_OPEN): [com.example.application]Activity@6e1ba65
11:24:30.219  D  [main] ApplicationService: current activity=null
11:24:30.220  D  [main] ApplicationService.handleLostFocus: application is now out of focus
11:24:30.220  D  [main] LocationController scheduleUpdate not possible, location shared not enabled
11:24:30.220  D  [main] OSBackgroundSync scheduleSyncServiceAsJob:atTime: 30000
11:24:30.223  I  [main] OSBackgroundSync scheduleSyncServiceAsJob:result: 1
11:24:30.223  D  [main] SessionService.onUnfocused()
11:26:16.211  D  [main] initWithContext(context: com.onesignal.core.services.SyncJobService@daad95, appId: null)
11:26:16.211  D  [main] Retrieving service interface com.onesignal.core.internal.background.IBackgroundManager
11:26:16.211  D  [main] Already instantiated: com.onesignal.core.internal.background.impl.BackgroundManager@fb4c446
11:26:16.212  D  [Thread-89] OSBackground sync, calling initWithContext
11:26:16.212  D  [Thread-89] SessionService.backgroundRun()
11:26:16.213  D  [Thread-89] SessionService: Session ended. activeDuration: 114001
11:26:16.213  D  [Thread-89] OperationRepo.enqueue(operation: {"name":"track-session-end","appId":"REDACTED","onesignalId":"REDACTED","sessionTime":114}, flush: false)
11:26:16.214  D  [Thread-89] LocationController scheduleUpdate not possible, location shared not enabled
11:26:16.214  D  [Thread-89] LollipopSyncRunnable:JobFinished needsJobReschedule: false
11:26:16.217  D  [DefaultDispatcher-worker-8] HttpClient: POST outcomes/measure - {"app_id":"REDACTED","onesignal_id":"REDACTED","subscription":{"id":"REDACTED","type":"AndroidPush"},"id":"os__session_duration","session_time":114}
11:26:16.407  D  [DefaultDispatcher-worker-8] HttpClient: POST outcomes/measure - STATUS: 202 JSON: {"success":true}
11:26:16.409  D  [Thread-91] OutcomeEventsCache.saveUniqueOutcomeEventParams(eventParams: OutcomeEventParams{outcomeId='os__session_duration', outcomeSource=OutcomeSource{directBody=null, indirectBody=OutcomeSourceBody{notificationIds=[], inAppMessagesIds=["c0d845f1-00e3-442c-9394-7223688d4d19"]}}, weight=0.0, timestamp=0, sessionTime=114})
11:26:16.414  D  [OpRepo] UpdateUserOperationExecutor(operation: [{"name":"track-session-end","appId":"REDACTED","onesignalId":"REDACTED","sessionTime":114,"id":"REDACTED"}])
11:26:16.415  D  [DefaultDispatcher-worker-2] HttpClient: PATCH apps/78188df7-d5e0-432d-9b41-373d5b28a4e2/users/by/onesignal_id/835d5039-d383-157a-b941-7402d862f0c1 - {"refresh_device_metadata":false,"deltas":{"session_time":114}}
11:26:16.624  D  [DefaultDispatcher-worker-2] HttpClient: PATCH apps/78188df7-d5e0-432d-9b41-373d5b28a4e2/users/by/onesignal_id/835d5039-d383-157a-b941-7402d862f0c1 - STATUS: 202 JSON: {"properties":{}}
11:26:16.625  D  [OpRepo] OperationRepo: execute response = SUCCESS

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions