Skip to content

Gate startup replay on prior-process eligibility - #1202

Open
snowp wants to merge 7 commits into
mainfrom
sp/startup-replay-crash-hint
Open

snowp wants to merge 7 commits into
mainfrom
sp/startup-replay-crash-hint

Conversation

@snowp

@snowp snowp commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Capture SDK now passes iOS prior-run confidence to shared-core’s startup replay gate. Before core startup, it initializes the existing previous-run controller only when cached crash_reporting.enabled permits monitoring, passes the controller’s hint to shared-core, and then reuses that controller unchanged for KSCrash and MetricKit’s later classification. A clean prior sentinel skips the delay; an unclean or unavailable state remains conservative. Android continues to use the conservative unknown eligibility.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Missing Android exit history is incorrectly treated as proof of no prior crash, allowing premature replay.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds platform-specific prior-run eligibility to shared-core’s startup replay gate.

Changes:

  • Derives eligibility from Android exit data and the iOS sentinel.
  • Threads eligibility through Swift/Rust and Kotlin/JNI bridges.
  • Updates shared-core pins, tests, and changelog.
File summaries
File Description
test/platform/swift/unit_integration/mocks/MockLoggerBridgingFactory.swift Records replay eligibility.
test/platform/swift/unit_integration/core/PreviousRunInfoControllerTests.swift Tests iOS sentinel classification.
test/platform/swift/unit_integration/core/network/helper/NetworkTestEnvironment.swift Supplies unknown eligibility.
test/platform/swift/unit_integration/core/LoggerTests.swift Tests iOS bridge propagation and gating.
platform/swift/source/StartupReplayEligibility.swift Defines Swift bridge values.
platform/swift/source/src/bridge.rs Passes iOS eligibility into shared-core.
platform/swift/source/reports/PreviousRunInfoRepository.m Adds read-only sentinel loading.
platform/swift/source/reports/PreviousRunInfoRepository.h Exposes sentinel loading API.
platform/swift/source/reports/previousRunInfo/PreviousRunInfoController.swift Classifies prior iOS termination.
platform/swift/source/LoggerBridgingFactoryProvider.swift Extends factory protocol.
platform/swift/source/LoggerBridgingFactory.swift Forwards eligibility.
platform/swift/source/LoggerBridge.swift Bridges eligibility to C/Rust.
platform/swift/source/Logger.swift Computes the gated iOS hint.
platform/swift/source/CaptureRustBridge.h Updates the C ABI.
platform/jvm/core/src/jni.rs Passes Android eligibility into shared-core.
platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/StartupReplayEligibilityTest.kt Verifies native values.
platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/reports/exitinfo/PreviousRunInfoResolverTest.kt Tests Android classifications.
platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/ConfigurationTest.kt Verifies bridge argument propagation.
platform/jvm/capture/src/test/kotlin/io/bitdrift/capture/CaptureLoggerNetworkTest.kt Updates native test setup.
platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/StartupReplayEligibility.kt Defines Android bridge values.
platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/reports/exitinfo/PreviousRunInfoResolver.kt Derives Android eligibility.
platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/LoggerImpl.kt Sends eligibility to JNI.
platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/IBridge.kt Extends the bridge contract.
platform/jvm/capture/src/main/kotlin/io/bitdrift/capture/CaptureJniLibrary.kt Updates the JNI declaration.
MODULE.bazel.lock Refreshes Bazel dependency state.
CHANGELOG.md Documents startup replay behavior.
Cargo.toml Pins the required shared-core revision.
Cargo.lock Refreshes Rust dependency resolution.
Review details
  • Files reviewed: 26/28 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

Android Size Comparison Report (x86_64)

Metric APK (KB) SO (KB)
Baseline 3480 1376
Current 3484 1377
Difference 4 1

APK size increased by 4 KB. SO size increased by 1 KB.

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

iOS Size Comparison Report

Metric Thinned App Size (KB) Capture SDK Binary (KB)
Baseline 3277 40309
Current 3277 40312
Difference 0 3

Thinned app size unchanged.
Capture SDK binary size increased by 3 KB.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The cross-platform ABI changes depend on still-open shared-core PR #628 and require final bridge verification.

Review details
  • Files reviewed: 26/28 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

@snowp
snowp force-pushed the sp/startup-replay-crash-hint branch from 9cc10de to 952f472 Compare September 10, 2026 16:59
@snowp
snowp requested a balanced review from Copilot September 10, 2026 20:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Current-run tracking starts too late, allowing a startup crash to leave a stale clean-exit sentinel.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 17/19 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment thread platform/swift/source/Logger.swift Outdated
Comment thread CHANGELOG.md Outdated
@snowp
snowp force-pushed the sp/startup-replay-crash-hint branch 3 times, most recently from 1d9131d to 5e0759b Compare September 10, 2026 21:35
@snowp
snowp requested a balanced review from Copilot September 14, 2026 15:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Current-run tracking still begins after core startup, leaving an untracked crash window.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 19/21 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread platform/swift/source/Logger.swift Outdated
Logger.issueReporterInitResult = (.initialized(.clientNotEnabled), 0)
Logger.previousRunInfoValue = .unknown
} else {
let isTrackingPreviousRun = previousRunInfoController?.startTrackingCurrentRun() == true
@snowp
snowp force-pushed the sp/startup-replay-crash-hint branch from 5e0759b to 1afb508 Compare September 14, 2026 15:57
@github-actions

Copy link
Copy Markdown

Android Benchmark Results

Device: PR: Emulator - Android SDK built for x86_64 (API 31) | main: Emulator - Android SDK built for x86_64 (API 31)

Note: Benchmarks run on emulator. Results may vary between runs and may differ from physical devices.

Allocations

Test PR main Δ
clearEntityId 0 0 0.0%
getSdkStatus 1 1 0.0%
logAppLaunchTTI 0 0 0.0%
logHttpNetworkLog50FieldsAndHeadersAndInitialFields 850 850 0.0%
logNotMatched5000Fields 10 10 0.0%
logNotMatchedNoFields 0 0 0.0%
loggerImplCreation 495 493 +0.4%
parseTreeWithOverlay 298 298 0.0%
parseTreeWithoutOverlay 298 298 0.0%
processJvmCrash 2253 2253 0.0%
processNativeCrash 2943 2943 0.0%
setEntityId 0 0 0.0%
startNewSession 0 0 0.0%
trackSpansWithFields 65 65 0.0%
trackSpansWithoutFields 45 45 0.0%
webViewBridgeBridgeReady 52 52 0.0%
webViewBridgeInvalidJson 38 38 0.0%

Timing

Test PR main Δ
clearEntityId 78 ns 118 ns -33.6%
getSdkStatus 166 ns 167 ns -0.9%
logAppLaunchTTI 90 ns 92 ns -1.8%
logHttpNetworkLog50FieldsAndHeadersAndInitialFields 208.96 us 204.60 us +2.1%
logNotMatched5000Fields 2.14 ms 1.93 ms +10.8%
logNotMatchedNoFields 689 ns 709 ns -2.8%
loggerImplCreation 1.25 ms 1.26 ms -0.9%
parseTreeWithOverlay 121.48 us 118.62 us +2.4%
parseTreeWithoutOverlay 167.35 us 162.01 us +3.3%
processJvmCrash 492.31 us 479.31 us +2.7%
processNativeCrash 441.83 us 415.18 us +6.4%
setEntityId 289 ns 362 ns -20.0%
startNewSession 528.79 us 512.55 us +3.2%
trackSpansWithFields 428.93 us 404.25 us +6.1%
trackSpansWithoutFields 7.82 us 7.90 us -1.1%
webViewBridgeBridgeReady 8.34 us 8.77 us -4.9%
webViewBridgeInvalidJson 201.04 us 102.67 us +95.8%

snowp and others added 7 commits September 15, 2026 09:58
Co-Authored-By: GPT-5 <codex@openai.com>
Co-Authored-By: GPT-5 <codex@openai.com>
Co-Authored-By: GPT-5 <codex@openai.com>
Keep the controller's early read-only state through startup and defer current-run sentinel creation until crash-reporter setup. Restore the PR's required shared-core revision after rebasing onto a base that predates it.

Co-Authored-By: GPT-5 <codex@openai.com>
Co-Authored-By: GPT-5 <codex@openai.com>
Co-Authored-By: GPT-5 <codex@openai.com>
Co-Authored-By: GPT-5 <codex@openai.com>
@snowp
snowp force-pushed the sp/startup-replay-crash-hint branch from 1afb508 to e2d8145 Compare September 15, 2026 14:06
@snowp
snowp requested a balanced review from Copilot September 15, 2026 19:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Failed logger construction can leave a false unclean-run sentinel that delays the next startup.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 15/15 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +183 to +185
let previousRunInfoController = CrashReporterService.isMonitoringEnabled(fromCachedConfigAt: directoryURL)
? PreviousRunInfoController(baseDirectory: directoryURL, osVersion: clientAttributes.osVersion)
: nil
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.

2 participants