Repository navigation
fix: Support new URLSession HTTP loader - #8845
Merged
Merged
Conversation
Track completion-handler data, download, and upload tasks when URLSession uses the Network framework HTTP loader. Preserve trace propagation and suppress duplicate wrapper-task spans. Refs #5045
Keep this branch focused on new-loader lifecycle support and restore copy-and-replace trace propagation. Move duplicate wrapper-task handling to a separate change.
philprime
force-pushed
the
philprime/fix/support-urlsession-http-loaders
branch
from
August 24, 2026 11:41
791dc04 to
c69265a
Compare
📲 Install BuildsiOS
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 8ebae2f | 1221.06 ms | 1250.28 ms | 29.22 ms |
| 6b08499 | 1216.67 ms | 1247.76 ms | 31.08 ms |
| 3efa7b5 | 1226.55 ms | 1260.66 ms | 34.11 ms |
| 53097d6 | 1218.02 ms | 1251.70 ms | 33.68 ms |
| 972e4d3 | 1244.02 ms | 1270.69 ms | 26.67 ms |
| 3658407 | 1221.23 ms | 1257.22 ms | 35.99 ms |
| 35901c8 | 1217.02 ms | 1259.13 ms | 42.11 ms |
| 58bec0e | 1222.40 ms | 1266.04 ms | 43.64 ms |
| d6af355 | 1214.83 ms | 1252.78 ms | 37.95 ms |
| 7d833a3 | 1226.72 ms | 1263.42 ms | 36.70 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 8ebae2f | 24.14 KiB | 1.23 MiB | 1.20 MiB |
| 6b08499 | 24.14 KiB | 1.15 MiB | 1.13 MiB |
| 3efa7b5 | 24.14 KiB | 1.22 MiB | 1.19 MiB |
| 53097d6 | 24.14 KiB | 1.16 MiB | 1.13 MiB |
| 972e4d3 | 24.14 KiB | 1.27 MiB | 1.24 MiB |
| 3658407 | 24.14 KiB | 1.23 MiB | 1.21 MiB |
| 35901c8 | 24.14 KiB | 1.24 MiB | 1.21 MiB |
| 58bec0e | 24.14 KiB | 1.33 MiB | 1.30 MiB |
| d6af355 | 24.14 KiB | 1.18 MiB | 1.15 MiB |
| 7d833a3 | 24.14 KiB | 1.16 MiB | 1.13 MiB |
Previous results on branch: philprime/fix/support-urlsession-http-loaders
Startup times
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 2cfb72d | 1209.18 ms | 1254.19 ms | 45.00 ms |
| 24ff139 | 1202.76 ms | 1261.37 ms | 58.61 ms |
| 41218fd | 1241.12 ms | 1276.83 ms | 35.71 ms |
| d7a9abe | 1212.02 ms | 1260.50 ms | 48.48 ms |
| eb26eed | 1243.04 ms | 1274.91 ms | 31.87 ms |
| ee32a50 | 1220.48 ms | 1260.58 ms | 40.10 ms |
| 61afc2c | 1230.82 ms | 1263.22 ms | 32.40 ms |
| b4af129 | 1226.89 ms | 1274.91 ms | 48.02 ms |
| f166b08 | 1225.07 ms | 1259.28 ms | 34.21 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 2cfb72d | 24.14 KiB | 1.33 MiB | 1.31 MiB |
| 24ff139 | 24.14 KiB | 1.34 MiB | 1.31 MiB |
| 41218fd | 24.14 KiB | 1.33 MiB | 1.31 MiB |
| d7a9abe | 24.14 KiB | 1.34 MiB | 1.31 MiB |
| eb26eed | 24.14 KiB | 1.33 MiB | 1.31 MiB |
| ee32a50 | 24.14 KiB | 1.31 MiB | 1.29 MiB |
| 61afc2c | 24.14 KiB | 1.31 MiB | 1.28 MiB |
| b4af129 | 24.14 KiB | 1.33 MiB | 1.31 MiB |
| f166b08 | 24.14 KiB | 1.34 MiB | 1.31 MiB |
Member
Author
|
@sentry review |
…-urlsession-http-loaders
Size Analysis1 component analyzed iOS Builds
|
Member
Author
|
@sentry review |
philprime
marked this pull request as ready for review
September 15, 2026 11:38
philprime
requested review from
NinjaLikesCheez,
itaybre and
noahsmartin
as code owners
September 15, 2026 11:38
philprime
marked this pull request as draft
September 15, 2026 12:10
Initialize replay details before response capture and add regressions. Account for copied classic setters in loader runtime assertions.
philprime
marked this pull request as ready for review
September 15, 2026 14:57
Merge origin/main while preserving new-loader instrumentation and task-lifetime protection. Capture replay method, headers, and body from the original request when completion follows a redirect.
NinjaLikesCheez
approved these changes
Sep 17, 2026
…-urlsession-http-loaders
philprime
marked this pull request as draft
September 17, 2026 08:24
Member
Author
|
Moved back to draft because I realized that this uses swizzling that should be gated by an experimental option first. |
Default new-loader instrumentation to an experimental opt-in. Gate retained hooks across restarts and report feature usage. Expose the option to Objective-C and test disabled and enabled paths.
Contributor
🚨 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:
|
Member
Author
|
@sentry review |
Member
Author
|
@NinjaLikesCheez re-requesting review because I added a new public option |
philprime
enabled auto-merge (squash)
September 17, 2026 09:14
philprime
disabled auto-merge
September 17, 2026 09:16
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 422fdb1. Configure here.
NinjaLikesCheez
approved these changes
Sep 17, 2026
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.

📜 Description
Support automatic network lifecycle instrumentation when
URLSessionConfiguration.usesClassicLoadingModeis disabled.The SDK discovers the new loader's runtime session and task classes and installs typed wrappers for completion-handler data, download, and upload tasks. This preserves span completion, breadcrumbs, failed-request capture, response status, and cancellation status.
Delegate-only new-loader tasks are intentionally not instrumented because the new loader does not expose the state transition used by the classic loader and replacing application delegates would change callback semantics. Trace propagation also remains unavailable for the new loader because it does not expose the copy-and-replace request setter used by the race-safe classic implementation.
Duplicate wrapper-task handling is split into #8846.
💡 Motivation and Context
Apple introduced a Network.framework-based HTTP loader that may become the default in a future OS release. Its private class hierarchy bypasses the classic
URLSessionTaskstate swizzles, causing missing automatic network lifecycle telemetry.Fixes #5045
💚 How did you test it?
make formatmake analyzemake build-macos FOR_AGENTS=truemake test-macos FOR_AGENTS=true TEST_PLAN=Sentry_TestServer📝 Checklist
You have to check all boxes before merging:
sendDefaultPIIis enabled.