Skip to content

fix: Crash with AVAssetDownloadTask in setState#7891

Merged
philprime merged 5 commits into
mainfrom
download_asset
May 11, 2026
Merged

fix: Crash with AVAssetDownloadTask in setState#7891
philprime merged 5 commits into
mainfrom
download_asset

Conversation

@itaybre
Copy link
Copy Markdown
Contributor

@itaybre itaybre commented May 8, 2026

Description

Fixes a regression introduced in 9.12.0 (#7588) where SentryNetworkTracker.urlSessionTask:setState: accesses sessionTask.originalRequest before the isTaskSupported: guard. AVAssetDownloadTask throws NSGenericException on that property, causing a 100% crash for any app using AVAssetDownloadURLSession.

The fix moves the isTaskSupported: check before the #if SENTRY_TARGET_REPLAY_SUPPORTED block that accesses originalRequest, restoring the guard order from 9.11.0.

Fixes #7886

How to test

  1. Create an AVAssetDownloadURLSession and call makeAssetDownloadTask(...).resume()
  2. Before this fix: crash with NSGenericException: AVAssetDownloadTask does not support originalRequest property
  3. After this fix: task resumes without crash

Checklist

  • I reviewed the submitted code
  • I added applicable tests — verified in simulator that AVAssetDownloadTask no longer crashes
  • No new PII or credentials are captured/stored

itaybre added 4 commits May 8, 2026 16:03
Move the isTaskSupported check before the replay network
details block that accesses originalRequest. Apple throws
NSGenericException when originalRequest is read on
AVAssetDownloadTask, which is not a supported task type.

Fixes #7886
@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label May 8, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

🚨 Detected changes in high risk code 🚨

High-risk code can easily blow up and is hard to test. We had severe bugs in the past. Be extra careful when changing these files, and have an extra careful look at these:

  • Sources/Sentry/SentryNetworkTracker.m

@sentry
Copy link
Copy Markdown

sentry Bot commented May 8, 2026

📲 Install Builds

iOS

🔗 App Name App ID Version Configuration
SDK-Size io.sentry.sample.SDK-Size 9.12.1 (1) Release

⚙️ sentry-cocoa Build Distribution Settings

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.533%. Comparing base (d0b52d1) to head (9251432).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7891       +/-   ##
=============================================
+ Coverage   85.489%   85.533%   +0.043%     
=============================================
  Files          487       487               
  Lines        29647     29647               
  Branches     12877     12897       +20     
=============================================
+ Hits         25345     25358       +13     
+ Misses        4250      4238       -12     
+ Partials        52        51        -1     
Files with missing lines Coverage Δ
Sources/Sentry/SentryNetworkTracker.m 97.759% <100.000%> (ø)

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d0b52d1...9251432. Read the comment docs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1220.82 ms 1250.00 ms 29.18 ms
Size 24.14 KiB 1.16 MiB 1.13 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
44b7b59 1211.91 ms 1248.90 ms 36.99 ms
8693a8f 1222.37 ms 1249.31 ms 26.95 ms
9319185 1223.24 ms 1249.98 ms 26.73 ms
d0b52d1 1227.31 ms 1258.32 ms 31.01 ms
1c5ecda 1219.35 ms 1253.76 ms 34.41 ms
ae8cece 1216.83 ms 1251.37 ms 34.55 ms
92bcc8f 1233.43 ms 1270.20 ms 36.77 ms
9c19a06 1217.77 ms 1248.98 ms 31.21 ms
c5c7a29 1223.14 ms 1258.55 ms 35.41 ms
71e6611 1213.27 ms 1242.25 ms 28.98 ms

App size

Revision Plain With Sentry Diff
44b7b59 24.14 KiB 1.15 MiB 1.13 MiB
8693a8f 24.14 KiB 1.16 MiB 1.13 MiB
9319185 24.14 KiB 1.16 MiB 1.13 MiB
d0b52d1 24.14 KiB 1.15 MiB 1.13 MiB
1c5ecda 24.14 KiB 1.15 MiB 1.12 MiB
ae8cece 24.14 KiB 1.15 MiB 1.13 MiB
92bcc8f 24.14 KiB 1.15 MiB 1.13 MiB
9c19a06 24.14 KiB 1.16 MiB 1.13 MiB
c5c7a29 24.14 KiB 1.15 MiB 1.13 MiB
71e6611 24.14 KiB 1.15 MiB 1.12 MiB

@itaybre itaybre marked this pull request as ready for review May 8, 2026 19:45
Copy link
Copy Markdown
Contributor

@NinjaLikesCheez NinjaLikesCheez left a comment

Choose a reason for hiding this comment

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

LGTM

@philprime philprime merged commit e56c394 into main May 11, 2026
212 checks passed
@philprime philprime deleted the download_asset branch May 11, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression in 9.12.0: crash with AVAssetDownloadTask in urlSessionTask:setState: — "does not support originalRequest property"

3 participants