Skip to content

Conversation

@ArielDemarco
Copy link
Member

Overview

Fixes #552 crash when instrumenting background URLSession tasks by detecting and skipping them based on their runtime class name.

Summary

Background URLSession tasks crash if you attempt to assign a delegate to them after creation. The instrumentation was trying to assign a FakeDelegate to capture completion events on resume, which caused the app to crash.

After digging deeper, background sessions require the delegate to be set when creating the session and don't support:

  • Async/await methods (data(from:), upload(for:), etc.)
  • Completion handler blocks
  • Delegate assignment after task creation

To solve this problem, it was added an extension (URLSessionTask.isBackground) that detects background tasks by checking their runtime class name against known background task classes.

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.

When using network instrumentation, network background tasks failes as the reported image.

1 participant