Skip to content

Reapply iOS SentrySDK.internal migration (#6380) after sentry-cocoa fixes screenshotSource lazy-var poisoning #6507

Description

@antonis

Follow-up to the revert in #6491 (which reverted #6380 to fix the iOS screenshot regression #6497).

Background

#6380 migrated iOS code from PrivateSentrySDKOnly to the new SentrySDK.internal Swift API. It shipped in 8.19.0 and broke all iOS screenshot capture (Feedback Widget screenshot, attachScreenshot, Sentry.captureScreenshot()) — see #6497. #6491 reverts #6380 as an interim fix.

Root cause (sentry-cocoa)

Any access to SentrySDK.internal constructs SentryInternalApi, whose init eagerly reads SentryDependencyContainer.screenshotSource. That property is a lazy var whose builder returns nil while startOptions is unset, and — being lazy — that nil is cached permanently. Because RN touches SentrySDK.internal before SentrySDK.start (from RNSentryStart and from JS integrations calling native methods like fetchNativeAppStart/fetchNativeSdkInfo during init), screenshotSource gets poisoned to nil and stays nil for the process lifetime.

A targeted RN-side fix is unreliable (any pre-start SentrySDK.internal access poisons it, and JS controls the timing), which is why we reverted the whole migration.

What needs to happen

  1. Fix in sentry-cocoascreenshotSource (and the other startOptions-gated lazy providers, e.g. viewHierarchyProvider) must not permanently cache nil. Options:
    • Make screenshotSource a computed property instead of a lazy var so getOptionalLazyVar rebuilds it once startOptions is available; and/or
    • Have SentryInternalApi read the providers lazily at use-time rather than eagerly in init.
  2. Bump the sentry-cocoa dependency in RN to the fixed version.
  3. Reapply refactor(ios): Migrate from PrivateSentrySDKOnly to SentrySDK.internal #6380 (revert the revert), re-verifying the feedback E2E flow stays green on iOS.

Notes

Related: #6380, #6491, #6497

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions