Skip to content

chore: FDv2 State Debouncing#344

Open
aaron-zeisler wants to merge 4 commits intomainfrom
aaronz/SDK-2001/fdv2-state-debouncing
Open

chore: FDv2 State Debouncing#344
aaron-zeisler wants to merge 4 commits intomainfrom
aaronz/SDK-2001/fdv2-state-debouncing

Conversation

@aaron-zeisler
Copy link
Copy Markdown
Contributor

@aaron-zeisler aaron-zeisler commented Apr 10, 2026

Details Coming Soon


Requirements

  • I have added test coverage for new or changed functionality
  • I have followed the repository's pull request submission guidelines
  • I have validated my changes against all supported platform versions

Related issues

Provide links to any issues in this repository or elsewhere relating to this pull request.

Describe the solution you've provided

Provide a clear and concise description of what you expect to happen.

Describe alternatives you've considered

Provide a clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context about the pull request here.


Note

Medium Risk
Changes FDv2 connection-mode switching timing by debouncing lifecycle/network transitions and adding immediate event-processor updates/flushes; regressions could cause delayed or missed data source rebuilds under rapid state changes.

Overview
Implements FDv2 state-change debouncing so rapid network/foreground transitions coalesce into a single data source rebuild (CONNMODE 3.5), via a new StateDebounceManager and updated ConnectivityManager wiring.

FDv2 listeners now update EventProcessor state immediately, flush events before backgrounding (CONNMODE 3.3.1), bypass debounce on identify() by recreating the debounce manager, and close the manager on shutdown; setForceOffline() remains immediate.

Adds a test-only LDConfig debounce override (debounceMs) and expands JVM/instrumented tests to cover debounce coalescing, identify bypass, background flush ordering, and shutdown behavior.

Reviewed by Cursor Bugbot for commit c134ebf. Bugbot is set up for automated code reviews on this repo. Configure here.

…ncing

Implements CONNMODE spec 3.5.1-3.5.4: a debounce manager that
coalesces rapid platform state changes (network, lifecycle, requested
mode) into a single reconciliation callback after a 1-second window.

This is a self-contained component with no ConnectivityManager changes.
Wiring into ConnectivityManager follows in the next commit.

Made-with: Cursor
@aaron-zeisler aaron-zeisler force-pushed the aaronz/SDK-2001/fdv2-state-debouncing branch 2 times, most recently from c91fb3b to 39781ed Compare April 10, 2026 20:09
…or FDv2

Integrates the debounce manager into FDv2 data source lifecycle:
- FDv2 network/lifecycle listeners route through debounce instead of
  immediate rebuild (CONNMODE 3.5.1-3.5.4)
- Event processor state updated immediately in listeners (not debounced)
- Events flushed before background transitions (CONNMODE 3.3.1)
- identify() bypasses debounce by destroying/recreating the manager
  (CONNMODE 3.5.6)
- setForceOffline() remains immediate (backward compatibility)
- FDv1 code path is unchanged

Adds integration tests for debounce coalescing, identify bypass,
event flush timing, force-offline bypass, and shutdown cleanup.

Made-with: Cursor
@aaron-zeisler aaron-zeisler force-pushed the aaronz/SDK-2001/fdv2-state-debouncing branch from 39781ed to aa1b6f3 Compare April 10, 2026 20:24
aaron-zeisler and others added 2 commits April 13, 2026 09:18
…d test timeouts

The 1-second StateDebounceManager debounce stacks with AndroidPlatformState's
500ms lifecycle debounce, causing LDClientDataSystemPlatformTest to exceed its
2-second timeouts on the CI emulator. Instead of inflating timeouts, add a
package-private debounceMs field to LDConfig so both unit and instrumented
tests can inject a short (50ms) debounce window.

- Add debounceMs field + getter to LDConfig, Builder setter (package-private)
- ConnectivityManager reads debounceMs from LDConfig instead of constructor arg
- Remove the second (test-visible) ConnectivityManager constructor
- ConnectivityManagerTest and LDClientDataSystemPlatformTest set debounceMs(50)

Made-with: Cursor
@aaron-zeisler aaron-zeisler marked this pull request as ready for review April 13, 2026 17:49
@aaron-zeisler aaron-zeisler requested a review from a team as a code owner April 13, 2026 17:49
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c134ebf. Configure here.

return;
if (!autoModeSwitchingConfig.isNetwork()) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debounce manager gets stale state when switching partially disabled

Medium Severity

When autoModeSwitchingConfig.isNetwork() is false, the connectivityChangeListener returns early without calling dm.setNetworkAvailable(), leaving the StateDebounceManager with stale network state. Symmetrically, when isLifecycle() is false, dm.setForeground() is never called. When the other (enabled) axis later triggers a debounce, handleDebouncedModeStateChange reads both dimensions from the debounce manager, causing resolveMode to use stale data — e.g., resolving to BACKGROUND when the network is actually offline, or STREAMING when the app is actually backgrounded.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c134ebf. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant