Skip to content

fix: WKWebView Logging Crash#662

Merged
BrandonStalnaker merged 2 commits intomainfrom
fix/SDKE-1114-WebView-Log-Crash
Mar 10, 2026
Merged

fix: WKWebView Logging Crash#662
BrandonStalnaker merged 2 commits intomainfrom
fix/SDKE-1114-WebView-Log-Crash

Conversation

@BrandonStalnaker
Copy link
Collaborator

Background

  • A crash was reported on the main thread in MParticleWebView.evaluateAgent() during user-agent collection via WKWebView.evaluateJavaScript. The stack trace showed the crash in objc_opt_respondsToSelector during string formatting inside MPLog.MPLogger (MParticleWebView.swift:80), with WebKit’s web process terminating and completion handlers running during shutdown. The failure occurred when the logging code treated a format argument as an object (for %@) and invoked a selector on it.

What Has Changed

  • MParticleWebView.swift (line 80): The retry-count log now uses the integer format specifier %d instead of %@. The value is an Int (self.retryCount); using %@ caused the format machinery to treat it as an object and led to the crash. Using %d formats the integer safely and removes this crash.

Checklist

  • I have performed a self-review of my own code.
  • I have tested this locally.

Reference Issue (For employees only. Ignore if you are an outside contributor)

@BrandonStalnaker BrandonStalnaker self-assigned this Mar 10, 2026
@BrandonStalnaker BrandonStalnaker requested a review from a team as a code owner March 10, 2026 19:00
@github-actions
Copy link

github-actions bot commented Mar 10, 2026

📦 SDK Size Impact Report

Measures how much the SDK adds to an app's size (with-SDK minus without-SDK).

Metric Target Branch This PR Change
App Bundle Impact 1.82 MB 1.82 MB +N/A
Executable Impact 896 bytes 896 bytes +N/A
XCFramework Size 9.49 MB 9.48 MB -4 KB

➡️ SDK size impact change is minimal.

Raw measurements

Target branch (main):

{"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1944,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1860,"sdk_executable_impact_bytes":896,"xcframework_size_kb":9716}

This PR:

{"baseline_app_size_kb":84,"baseline_executable_size_bytes":75464,"with_sdk_app_size_kb":1944,"with_sdk_executable_size_bytes":76360,"sdk_impact_kb":1860,"sdk_executable_impact_bytes":896,"xcframework_size_kb":9712}

Copy link
Contributor

@denischilik denischilik left a comment

Choose a reason for hiding this comment

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

Just small nit

Copy link
Contributor

@denischilik denischilik left a comment

Choose a reason for hiding this comment

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

LGTM

@BrandonStalnaker BrandonStalnaker merged commit edaa25c into main Mar 10, 2026
26 of 27 checks passed
@BrandonStalnaker BrandonStalnaker deleted the fix/SDKE-1114-WebView-Log-Crash branch March 10, 2026 20:18
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.

4 participants