Skip to content

Fix decoded image cache concurrency deadlock#6907

Merged
vegaro merged 2 commits into
mainfrom
cursor/fix-decoded-image-cache-deadlock-fb06
Jun 4, 2026
Merged

Fix decoded image cache concurrency deadlock#6907
vegaro merged 2 commits into
mainfrom
cursor/fix-decoded-image-cache-deadlock-fb06

Conversation

@vegaro

@vegaro vegaro commented Jun 4, 2026

Copy link
Copy Markdown
Member

Motivation

Paywalls can request several cached images from Swift concurrency tasks during first presentation. DecodedImageCache wrapped NSCache access in a concurrent DispatchQueue using synchronous reads and asynchronous barrier writes. Blocking Swift cooperative pool threads on that GCD queue can starve the pool and deadlock image loading, which can also prevent subscriber actions from running.

Description

  • Removed the extra GCD queue from DecodedImageCache and use NSCache directly, since NSCache is thread-safe.
  • Added a regression test that launches many unique decoded image loads from Swift concurrency and asserts they complete. This reproduced a deadlock as a timeout without the fix

Slack Thread

Open in Web Open in Cursor 

Co-authored-by: Cesar de la Vega <vegaro@users.noreply.github.com>
@vegaro vegaro added pr:fix A bug fix pr:RevenueCatUI labels Jun 4, 2026 — with Cursor
@rickvdl

rickvdl commented Jun 4, 2026

Copy link
Copy Markdown
Member

@RCGitBot please test

Co-authored-by: Cesar de la Vega <vegaro@users.noreply.github.com>
@vegaro vegaro marked this pull request as ready for review June 4, 2026 14:15
@vegaro vegaro requested review from a team as code owners June 4, 2026 14:15

@rickvdl rickvdl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for fixing and your thorough investigation!

@vegaro vegaro merged commit e4f3f7f into main Jun 4, 2026
18 of 20 checks passed
@vegaro vegaro deleted the cursor/fix-decoded-image-cache-deadlock-fb06 branch June 4, 2026 14:45
@bilqisium

Copy link
Copy Markdown
Contributor

Thanks @vegaro for this fix! Already fixing an issue in a ticket!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants