You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue is affecting the React native Android Widgets.
The Onesignal package is causing widgets to update when opening/closing any activity, causing reloads and unnecessary refreshes. The intent action ACTION_APPWIDGET_UPDATE should be sent when the app widget provider is instantiated or when the update interval causes it to update (docs).
What I think is happening is that the app widget provider is being reinitialized since the action is being sent more than it should and the widget view is not refreshing/updating but instead being "restarted". Before adding the package when the widget would refresh the values would be updated, now the view returns to an empty state and re-fetches everything. I've also noticed the widget gets refreshed more than usual when observing logs. The update interval we have set is every 30 minutes but it seems like it's getting updated every 3-6 minutes, which could be taking a lot of battery life.
Keep in mind that in the logs below the widget should not be updating at all in these scenarios, and work accordingly when onesignal is removed from the project.
The logs below is what happens when the activity is put into the background and I've highlighted where the widget get's updated with arrows.
On activity close/background
D/OneSignal: onActivityPaused: web.project.com.MainActivity@70949f0
D/OneSignal: ActivityLifecycleHandler Handling lost focus
D/OneSignal: Application stopped focus time: 275926580 timeElapsed: 109
D/OneSignal: FocusTimeProcessorUnattributed:saveUnsentActiveData with lastFocusTimeInfluences: [SessionInfluence{influenceChannel=iam, influenceType=UNATTRIBUTED, ids=null}, SessionInfluence{influenceChannel=notification, influenceType=UNATTRIBUTED, ids=null}]
D/OneSignal: FocusTimeProcessorUnattributed:getUnsentActiveTime: 36
D/OneSignal: FocusTimeProcessorUnattributed:saveUnsentActiveTime: 145
D/OneSignal: curActivity is NOW: null
D/OneSignal: onActivityStopped: web.project.com.MainActivity@70949f0
D/OneSignal: curActivity is NOW: null
D/OneSignal: Running destroyTimeout with runnable: com.onesignal.OSFocusHandler$startOnStopFocusWork$1@b82c1a1
D/OneSignal: Running startTimeout with timeout: 1500 and runnable: com.onesignal.OSFocusHandler$startOnStopFocusWork$1@b82c1a1
-----> V/WIDGET_UPDATE: intent action: android.appwidget.action.APPWIDGET_UPDATE
-----> V/WIDGET_UPDATE: onUpdate called
D/OneSignal: OSFocusHandler running onAppLostFocus
D/OneSignal: Application lost focus initDone: true
D/OneSignal: Last session time set to: 1653407136241
D/OneSignal: GMSLocationController onFocusChange!
D/OneSignal: Application backgrounded focus time: 275926580
D/OneSignal: FocusTimeProcessorUnattributed:getUnsentActiveTime: 145
D/OneSignal: FocusTimeProcessorUnattributed:sendUnsentTimeNow with time: 145 and influences: []
D/OneSignal: FocusTimeProcessorUnattributed sendTime with: BACKGROUND
D/OneSignal: FocusTimeProcessorUnattributed:getUnsentActiveTime: 145
V/OneSignal: OSSyncService scheduleSyncTask:SYNC_AFTER_BG_DELAY_MS: 30000
V/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:atTime: 30000
I/OneSignal: OSBackgroundSync scheduleSyncServiceAsJob:result: 1
D/OneSignal: OneSignal scheduleSyncService unsyncedChanges: false
D/OneSignal: LocationController scheduleUpdate not possible, location permission not enabled
D/OneSignal: OneSignal scheduleSyncService locationScheduled: false
D/OneSignal: OSFocusHandler setting stop state: true
-----> V/WIDGET_UPDATE: intent action: android.appwidget.action.APPWIDGET_UPDATE
-----> V/WIDGET_UPDATE: onUpdate called
On activity open
D/OneSignal: OSFocusHandler running onAppStartFocusLogic
D/OneSignal: onActivityResumed: web.project.com.MainActivity@70949f0
D/OneSignal: curActivity is NOW: web.project.com.MainActivity:web.project.com.MainActivity@70949f0
D/OneSignal: ActivityLifecycleHandler handleFocus, nextResumeIsFirstActivity: false
D/OneSignal: ActivityLifecycleHandler reset background state, call app focus
D/OneSignal: OSFocusHandler running onAppFocus
D/OneSignal: Application on focus
D/OneSignal: GMSLocationController onFocusChange!
D/OneSignal: Application foregrounded focus time: 276276715
D/OneSignal: isPastOnSessionTime currentTimeMillis: 1653407375600 lastSessionTime: 1653407136241 difference: 239359
D/OneSignal: Starting new session with appEntryState: APP_OPEN
D/OneSignal: OneSignal cleanOutcomes for session
D/OneSignal: OneSignal save unattributedUniqueOutcomeEvents: []
D/OneSignal: OneSignal SessionManager restartSessionIfNeeded with entryAction: APP_OPEN
influenceType=UNATTRIBUTED, indirectIds=null, directId=null}, OSChannelTracker{tag=iam_id, influenceType=UNATTRIBUTED, indirectIds=null, directId=null}]
D/OneSignal: OneSignal ChannelTracker getLastReceivedIds lastChannelObjectReceived: []
D/OneSignal: OneSignal SessionManager restartSessionIfNeeded lastIds: []
D/OneSignal: OneSignal ChannelTracker getLastReceivedIds lastChannelObjectReceived: []
D/OneSignal: OneSignal SessionManager restartSessionIfNeeded lastIds: []
D/OneSignal: OneSignal SessionManager sendSessionEndingWithInfluences with influences: []
D/OneSignal: Last session time set to: 1653407375602
D/OneSignal: initWithCachedInAppMessages: null
I/OneSignal: Location permissions not added on AndroidManifest file
D/OneSignal: LocationController sendAndClearPromptHandlers from non prompt flow
D/OneSignal: registerUser:registerForPushFired:true, locationFired: true, remoteParams: com.onesignal.OneSignalRemoteParams$2@1d51105, appId: hidden_id
D/OneSignal: LocationController scheduleUpdate not possible, location permission not enabled
D/OneSignal: OSSyncService cancel background sync
I/OneSignal: Device registered, push token = hidden_token
D/OneSignal: registerForPushToken completed with id: hidden_id status: 1
D/OneSignal: registerUser:registerForPushFired:true, locationFired: true, remoteParams: com.onesignal.OneSignalRemoteParams$2@1d51105, appId: hidden_id
D/OneSignal: registerUserTask calling readyToUpdate
E/OneSignal: Already initialized the OneSignal React-Native SDK
D/OneSignal: registerUserTask calling readyToUpdate
-----> V/WIDGET_UPDATE: intent action: android.appwidget.action.APPWIDGET_UPDATE
-----> V/WIDGET_UPDATE: onUpdate called
D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: true jsonBody: {"app_id":"hidden_id"}
D/OneSignal: OneSignalRestClient: Making request to: https://api.onesignal.com/players/hidden_id/on_session
D/OneSignal: OneSignalRestClient: POST SEND JSON: {"app_id":"hidden_id"}
V/OneSignal: OneSignalRestClient: After con.getResponseCode to: https://api.onesignal.com/players/hidden_idon_session
D/OneSignal: OneSignalRestClient: Successfully finished request to: https://api.onesignal.com/players/hidden_id/on_session
D/OneSignal: OneSignalRestClient: POST RECEIVED JSON: {"success":true,"id":"hidden_id"}
D/OneSignal: doCreateOrNewSession:response: {"success":true,"id":"hidden_id"}
I/OneSignal: Device registered, UserId = hidden_id
D/OneSignal: UserStateSynchronizer internalSyncUserState from session call: false jsonBody: null
-----> V/WIDGET_UPDATE: intent action: android.appwidget.action.APPWIDGET_UPDATE
-----> V/WIDGET_UPDATE: onUpdate called
Here's the logs that show the widget's being updated every 3-6 minutes:
jkasten2
changed the title
Onesignal React Native: Package breaks Android widgets
Onesignal React Native: Package causes Android widgets onUpdate each time app is opened and closed
Jun 28, 2022
Description:
This issue is affecting the React native Android Widgets.
The Onesignal package is causing widgets to update when opening/closing any activity, causing reloads and unnecessary refreshes. The intent action
ACTION_APPWIDGET_UPDATE
should be sent when the app widget provider is instantiated or when the update interval causes it to update (docs).What I think is happening is that the app widget provider is being reinitialized since the action is being sent more than it should and the widget view is not refreshing/updating but instead being "restarted". Before adding the package when the widget would refresh the values would be updated, now the view returns to an empty state and re-fetches everything. I've also noticed the widget gets refreshed more than usual when observing logs. The update interval we have set is every 30 minutes but it seems like it's getting updated every 3-6 minutes, which could be taking a lot of battery life.
Keep in mind that in the logs below the widget should not be updating at all in these scenarios, and work accordingly when onesignal is removed from the project.
The logs below is what happens when the activity is put into the background and I've highlighted where the widget get's updated with arrows.
On activity close/background
On activity open
Here's the logs that show the widget's being updated every 3-6 minutes:
Environment
Steps to Reproduce Issue:
android.appwidget.action.APPWIDGET_UPDATE
is called.Anything else:
Thanks for investigating!
The text was updated successfully, but these errors were encountered: