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
We don't seem to be able to get rid of calling getConnectionStatus() on connectivity change, as the NetworkCallback seems to fire for any network, e.g. reporting a disconnect of WIFI, although Cellular connection is still available.
But I noticed every internal IConnectionStatusObserver was tied to it's own NetworkCallback, causing us to call getConnectionStatus() per change per observer - which quickly blows our number of IPC calls up.
So instead let's have a single NetworkCallback, call getConnectionStatus() once per network change and then broadcast the state to all observers. This should already reduce the number of IPC calls by 3.
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine, I'm using a lock mechanism for safe access and there aren't many writes to this list: In my testing there were 3 listeners attached.
Oh btw, I also thought of maybe persisting the last known connection status in AndroidConnectionStatusProvider so we don't have to do IPC (getActiveNetworkInfo) when we want to know the current status at a certain moment in time? In that case we'd probably have to registerNetworkCallback in the AndroidConnectionStatusProvider ctor so we always have access to the last known state after the SDK is initialized.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
We don't seem to be able to get rid of calling
getConnectionStatus()on connectivity change, as the NetworkCallback seems to fire for any network, e.g. reporting a disconnect of WIFI, although Cellular connection is still available.But I noticed every internal
IConnectionStatusObserverwas tied to it's ownNetworkCallback, causing us to callgetConnectionStatus()per change per observer - which quickly blows our number of IPC calls up.So instead let's have a single
NetworkCallback, callgetConnectionStatus()once per network change and then broadcast the state to all observers. This should already reduce the number of IPC calls by 3.💡 Motivation and Context
Less IPC calls
Fixes #4053
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps