-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix reading the local database state just after the initial write #3373
Conversation
b6511ca
to
eef353b
Compare
SDK Size
|
let expectation1 = expectation(description: "onWillChange is called") | ||
observer.onWillChange = { | ||
expectation1.fulfill() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because data is accessible as soon as startObserving is called, I removed the will change delegate because it does not really make sense anymore (we allow immediate access). I kept the didChange because we still do async loading.
eef353b
to
a768177
Compare
SDK Performance
|
SDK Size
|
a768177
to
cc447e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Wise looks good. But we need to make sure the benchmark passes and also we should do some smoke testing CC @testableapple
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good ✅ Please check the failed performance benchmarks before merging
…duce latency of the database observer
cc447e1
to
44b2f48
Compare
…g state although it was already sent
… considered to be stable now
Quality Gate passedIssues Measures |
Manually triggered performance job here |
* main: (154 commits) Unblock release on workflow dispatch (GetStream#3389) [CI] Run release action on workflow dispatch (GetStream#3386) [CI] Do not unshallow branches on CI [CI] Do not unshallow branches on CI [CI] Update git config on merging develop and release branches [CI] Update git config on merging develop and release branches [CI] Pull origin release branch on release [CI] Pull origin release branch on release [CI] Fetch all branches on release (GetStream#3385) [CI] Fetch all branches on release (GetStream#3385) Bump 4.62.0 Store pending message along with regular messages (GetStream#3378) [CI] Set up a default base branch when automatically creating PRs (GetStream#3383) Fix reading the local database state just after the initial write (GetStream#3373) [CI] Add space to SDK size badge (GetStream#3379) Update channel type documentation to reflect allowed characters (GetStream#3377) Reuse CurrentChatUserController instead of recreating it when sending typing events (GetStream#3372) Run offline state sync in the background (GetStream#3367) [CI] Bump fastlane plugin version (GetStream#3376) [CI] Bump fastlane actions plugin (GetStream#3375) ...
🔗 Issue Links
Resolves PBE-5519
🎯 Goal
synchronize()
's completion block when the initial DB state was empty📝 Summary
OperationQueue
from theBackgroundDatabaseObserver
(less latency)🛠 Implementation
BackgroundDatabaseObserver
tries to load the initial state as soon as observing starts using a background thread (less blocking of the main thread). Since it is an async operation, there is a data race between loading the initial state and the managed object context changing at the same time. For avoiding it, the observer keeps an internal state to figure out when it can use the cached items array. This internal state was incorrect if the DB was empty and there just was a DB write as well. The observer's implementation is similar to theStateLayerDatabaseObserver
now where we use NSManagedObjectContext's thread for processing and accessing the state (better data consistency).Account Chewbacca in the demo app:
🧪 Manual Testing Notes
Account: Chewbacca
Exploratory testing (because DB observers affect all the controllers)
☑️ Contributor Checklist