Skip to content

Fix #2282: Add adaptive polling with exponential backoff for LiveUpdate#2423

Merged
anshu10sep merged 1 commit intomainfrom
fix/2282-live-update-auto-pause
Apr 16, 2026
Merged

Fix #2282: Add adaptive polling with exponential backoff for LiveUpdate#2423
anshu10sep merged 1 commit intomainfrom
fix/2282-live-update-auto-pause

Conversation

@anshu10sep
Copy link
Copy Markdown
Collaborator

Summary

Implements exponential backoff for LiveUpdate polling to prevent Figma rate limiting during long sessions.

Problem

LiveUpdate polls Figma every 5 seconds unconditionally. During long development sessions with no active Figma changes, this exhausts the Figma API rate limit, resulting in 'Too many requests to Figma.com' errors.

This was exacerbated by Figma's introduction of rate limits in November 2025.

Solution

Adaptive polling with exponential backoff:

Consecutive Unchanged Interval
0 (change detected) 5s (base)
1 10s
2 20s
3 40s
4+ 60s (max)

When a document change is detected, the interval resets to 5s immediately. The interval also resets when live updates are explicitly restarted (activity resume, toggle).

Changes

  • DocServer.kt:
    • Added MAX_FETCH_INTERVAL_MILLIS (60s), currentFetchIntervalMillis, and consecutiveUnchangedCount fields
    • scheduleLiveUpdate() uses currentFetchIntervalMillis instead of hardcoded interval
    • startLiveUpdates() resets interval and counter on explicit start
    • fetchDocuments() increments/resets backoff based on whether document changed
    • Added info-level logs for interval changes

Validation

  • ./gradlew designcompose:compileDebugKotlin: ✅
  • ./gradlew spotCheck: ✅
  • Backoff logic uses bit-shift (1L shl n) capped to 4 shifts max, ensuring interval never exceeds 60s

Fixes #2282

LiveUpdate previously polled Figma every 5 seconds unconditionally,
which triggered rate limiting ('Too many requests') during long
sessions.

This change implements exponential backoff for the polling interval:
- After each consecutive unchanged response, the interval doubles
  (5s → 10s → 20s → 40s → 60s max)
- When a document change is detected, the interval resets to 5s
- When live updates are explicitly started (resume, toggle),
  the interval resets to 5s

This significantly reduces API calls during idle editing periods
while still providing responsive updates when the designer is
actively making changes.

Interval progression:
  Change 0: 5s (base)
  No change 1: 10s
  No change 2: 20s
  No change 3: 40s
  No change 4+: 60s (max)
  Document changes: → 5s (reset)
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 44.03%. Comparing base (af5409b) to head (e075cb6).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2423      +/-   ##
============================================
- Coverage     44.05%   44.03%   -0.03%     
  Complexity       19       19              
============================================
  Files            39       39              
  Lines          4444     4444              
  Branches         51       51              
============================================
- Hits           1958     1957       -1     
- Misses         2472     2473       +1     
  Partials         14       14              
Flag Coverage Δ
kotlin 72.17% <ø> (ø)
rust 41.66% <ø> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

Snapshot diff report vs base branch: main
Last updated: Thu Apr 9 21:13:13 PDT 2026, Sha: e075cb6
No differences detected

@anshu10sep anshu10sep requested a review from dipenpradhan April 10, 2026 05:12
@anshu10sep anshu10sep enabled auto-merge April 10, 2026 05:12
@anshu10sep anshu10sep added this pull request to the merge queue Apr 16, 2026
// unchanged responses. The interval increases exponentially (5s -> 10s -> 20s -> 40s -> 60s)
// when no changes are detected, and resets to FETCH_INTERVAL_MILLIS when a document changes.
// This reduces Figma API calls and avoids rate limiting. (Issue #2282)
internal var currentFetchIntervalMillis: Long = FETCH_INTERVAL_MILLIS
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We need to add this into the Jekyll docs and README, updating #2379 to add the documentation and switch to this variable currentFetchIntervalMillis,

Merged via the queue into main with commit a30d6d9 Apr 16, 2026
23 checks passed
@anshu10sep anshu10sep deleted the fix/2282-live-update-auto-pause branch April 16, 2026 03:21
dipenpradhan added a commit that referenced this pull request Apr 22, 2026
Create v0.39.0-RC02 


v0.39.0-RC01(#2446)
This commit bumps the version across all Gradle
(`gradle/libs.versions.toml`) and Cargo configuration files to `0.39.0`
(`0.39.0-SNAPSHOT` in Gradle). It also unifies the
`dc_squoosh_animation` and `dc_squoosh_parser` crates under the
workspace dependencies.

Changes and issues addressed since 0.38.4:
- Enhance LiveUpdate feature (Issues
#2282,
#2379)
- Add cargo publish steps to GitHub release workflow (Issues
#2435,
#2436)
- Squoosh Designer Plugin: Figma plugin for orchestrating layout
animations (Issue
#2402)
- Replace println!/eprintln! with Rust log API in library code (Issues
#2403,
#2411)
- Update dc_figma_import README to reflect current architecture (Issues
#426,
#2427)
- Add comprehensive unit tests for mergeStyles function (Issues
#1963,
#2416)
- Avoid double key events during animated transitions (Issues
#1514,
#2417)
- Clean up unwrap() calls in dc_jni crate (Issues
#670,
#2415)
- Security: Update rustls-webpki 0.103.10 -> 0.103.12 (Issue
#2434)
- Document supported Android SDK levels (Issues
#163,
#2429)
- Restore Modifier customization support in squoosh renderer (Issues
#2292,
#2426)
- Handle unknown Figma features in deserialization (Issues
#2305,
#2414)
- Add adaptive polling with exponential backoff for LiveUpdate (Issues
#2282,
#2423)
- Add comprehensive Rust layout unit tests (Issues
#405,
#2413)
- Update JNI dependency to 0.22.4 and refactor dc_jni (Issue
#2432)
- Enable CodeQL security scanning (Issues
#926,
#2412)
- Prevent Design Switcher from briefly showing 'Offline' (Issues
#142,
#2421)
- Stroke gradients account for stroke thickness (Issues
#1549,
#2420)
- Add performance logging for high-cost fetch operations (Issues
#281,
#2419)
- Remove unclaimed Open VSX extension recommendation (Issue
#2431)
- Add assembleRelease to CI to catch minified build issues (Issues
#435,
#2425)
- Deprecate and remove publish_designcompose.sh script (Issue
#2433)
- Clarify visibility documentation — parameter name is flexible (Issues
#660,
#2428)
- Add JDK installation instructions to Getting Started docs (Issues
#707,
#2424)
- Add security check for Figma token file permissions (Issues
#249,
#2418)
- Fix whilePressing interaction getting stuck on multi-touch drag (Issue
#2422)
- Fix SquooshRoot infinite recomposition and freeze on rapid tap (Issue
#2409)
- Fix #436:
Tutorial release build signing configuration
(#2437)
- Fix #291:
Progress marker alignment in nested instances
(#2444)
- Fix #244:
Rotated node margin calculation uses pre-rotation size
(#2439)

---------

Co-authored-by: anshu10sep <priyanksingh@google.com>
kovmarci86 pushed a commit to kovmarci86/automotive-design-compose that referenced this pull request Apr 22, 2026
This commit bumps the version across all Gradle
(`gradle/libs.versions.toml`) and Cargo configuration files to `0.39.0`
(`0.39.0-SNAPSHOT` in Gradle). It also unifies the
`dc_squoosh_animation` and `dc_squoosh_parser` crates under the
workspace dependencies.

Changes and issues addressed since 0.38.4:
- Enhance LiveUpdate feature (Issues google#2282, google#2379)
- Add cargo publish steps to GitHub release workflow (Issues google#2435,
google#2436)
- Squoosh Designer Plugin: Figma plugin for orchestrating layout
animations (Issue google#2402)
- Replace println!/eprintln! with Rust log API in library code (Issues
google#2403, google#2411)
- Update dc_figma_import README to reflect current architecture (Issues
google#426, google#2427)
- Add comprehensive unit tests for mergeStyles function (Issues google#1963,
google#2416)
- Avoid double key events during animated transitions (Issues google#1514,
google#2417)
- Clean up unwrap() calls in dc_jni crate (Issues google#670, google#2415)
- Security: Update rustls-webpki 0.103.10 -> 0.103.12 (Issue google#2434)
- Document supported Android SDK levels (Issues google#163, google#2429)
- Restore Modifier customization support in squoosh renderer (Issues
google#2292, google#2426)
- Handle unknown Figma features in deserialization (Issues google#2305, google#2414)
- Add adaptive polling with exponential backoff for LiveUpdate (Issues
google#2282, google#2423)
- Add comprehensive Rust layout unit tests (Issues google#405, google#2413)
- Update JNI dependency to 0.22.4 and refactor dc_jni (Issue google#2432)
- Enable CodeQL security scanning (Issues google#926, google#2412)
- Prevent Design Switcher from briefly showing 'Offline' (Issues google#142,
google#2421)
- Stroke gradients account for stroke thickness (Issues google#1549, google#2420)
- Add performance logging for high-cost fetch operations (Issues google#281,
google#2419)
- Remove unclaimed Open VSX extension recommendation (Issue google#2431)
- Add assembleRelease to CI to catch minified build issues (Issues google#435,
google#2425)
- Deprecate and remove publish_designcompose.sh script (Issue google#2433)
- Clarify visibility documentation — parameter name is flexible (Issues
google#660, google#2428)
- Add JDK installation instructions to Getting Started docs (Issues
google#707, google#2424)
- Add security check for Figma token file permissions (Issues google#249,
google#2418)
- Fix whilePressing interaction getting stuck on multi-touch drag (Issue
google#2422)
- Fix SquooshRoot infinite recomposition and freeze on rapid tap (Issue
google#2409)
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.

Allow auto pause and resume functionality for LiveUpdate.

3 participants