Keep a view ID resolving after a background and foreground cycle - #603
Draft
arifBurakDemiray wants to merge 1 commit into
Draft
arifBurakDemiray wants to merge 1 commit into
arifBurakDemiray wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Dependency security scanScanned 515 resolved dependencies — 289 buildscript, 14 published, 212 sample.
Below the HIGH threshold, but ours to upgrade (1)
Waived via allowlist (2)
88 further finding(s) in Gradle plugin internals are reported in the job summary and the Result: passed |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Board card C-2: A view ID stops working after a background and foreground cycle
Primary source: the
swift-sdk-review-2026-09-24code-review sweep. The card namescountly-sdk-swift'sViewsModule(restartedViewIDs,currentID(for:)) as the reference implementation.What breaks without this
ModuleViews.startStoppedViewsreopens every view that was closed on background under a new view ID and drops the oldviewDataMapentry. A host that saved the ID returned bystartViewand later callsstopViewWithIDwith it hits an unknown ID once the app has been backgrounded:there is no view with the provided view id to close,visitand a duration on every later foreground while the user is on other screens.The same applies to
pauseViewWithID,resumeViewWithIDandaddSegmentationToViewWithID.Nothing on the wire changes. Only the ID the host holds has to keep resolving.
What changed
sdk/src/main/java/ly/count/android/sdk/ModuleViews.java:restartedViewIDsmap from each handed-out view ID to the ID its view is open under now.currentIDFor(String)resolves a host-held ID, returning the input unchanged when the view was never restarted.rememberRestartedView(old, new)repoints existing entries that pointed at the old ID and addsold -> new, so an ID survives repeated background cycles.forgetRestartedView(id)drops every entry keyed by or pointing at an ID when the view is finally stopped. Called fromstopViewWithIDInternal(the!willStartAgainbranch), fromautoCloseRequiredViewswhen it closes all views, and fromstartStoppedViewswhen a view could not be reopened.stopViewWithIDInternal,pauseViewWithIDInternal,resumeViewWithIDInternalandaddSegmentationToViewWithIDInternalresolve throughcurrentIDForafter their null check. Internal callers pass an already-current ID, whichcurrentIDForreturns unchanged.sdk/src/androidTest/.../ModuleViewsTests.java: regression teststartView_viewIDResolvesAfterBackgroundForegroundasserting the saved ID still closes the view after anonStop/onStartcycle and that nothing is left behind.CHANGELOG.md: one entry under the unreleased## XX.XX.XXheading.No public API change, no minimum version change.
What I did not verify
ModuleViewsTestslives inandroidTestand needs a device or emulator; none was attached on the machine that produced this branch. The new test has never been executed.:sdk:compileDebugJavaWithJavacand:sdk:compileDebugAndroidTestJavaWithJavacboth pass on JDK 17.countly-sdk-swiftimplementation was not read; the behaviour here follows the card's description of it, not the Swift source.🤖 Generated with Claude Code