Skip to content

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Aug 8, 2025

WOOMOB-660

Description

This PR fixes a crash occurring on iOS 26 when converting certain NSError values into ErrorCode using ErrorCode(_nsError:).

Problem

On iOS 26, some NSError instances, especially those from the Stripe SDK, cause a fatal crash when converted to ErrorCode and accessed or logged (e.g., print(errorCode.code)).
This crash does not occur on iOS 18.5, including on simulators.

Example that triggers the crash:

let errorCode = ErrorCode(_nsError: NSError(domain: "com.stripe.terminal", code: 2020, userInfo: [:]))
print(errorCode.code) // Fatal error on iOS 26

Notably, not all error codes cause this behavior. Some values are fine, while others fail, regardless of whether the code is valid or known to the Stripe SDK.

The issue can be seen using lldb

(lldb) po ErrorCode(_nsError: NSError(domain: "com.stripe.terminal", code: 2020, userInfo: [:])).code

SignalCompression/SignalEncoder.swift:261: Fatal error: Unknown error
.SCPErrorCanceled

Solution

For now, avoid calling errorCode.code, and calling errorCode.errorCode instead.

We will get in logs:

💳 Stripe Error Code: 2020

instead of

💳 Stripe Error Code: SCPError(rawValue: 2020)

Stripe Report: stripe/stripe-terminal-ios#362


Steps to reproduce

I only tested on iPadOS 26 (simulator and device), and wasn't able to check iPhone TTP crashes. To reproduce a crash on iPadOS:

  1. Turn on simulated card reader
  2. Open POS
  3. Connect to card reader
  4. Check out
  5. Come back to cancel the order
  6. It should crash on trunk without the fix, and shouldn't fix here

Testing information

Additionally, it was tested on an iOS 26 device and there's no more crash. There's only an expected "unsupported software version" since TTP shouldn't work on the beta releases (https://docs.stripe.com/terminal/payments/setup-reader/tap-to-pay?platform=ios#supported-devices)

Screenshots


  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

Some NSError values, when converted to ErrorCode using ErrorCode(_nsError:), cause a crash on iOS 26 — even if they represent known error codes like .SCPErrorCanceled.
This does not occur on iOS 18.5 (including simulators), where the same code executes without issue.
Crashes occur inconsistently across error codes and are triggered during logging or property access (e.g. print(errorCode.code)), with messages like:
Fatal error: Unknown error at SignalCompression/SignalEncoder.swift.

This commit avoids triggering such conversions/logging that may crash on iOS 26.
@staskus staskus added this to the 23.1 milestone Aug 8, 2025
@staskus staskus added type: crash The worst kind of bug. feature: mobile payments Related to mobile payments / card present payments / Woo Payments. feature: POS labels Aug 8, 2025
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 8, 2025

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr16000-1a11ed7
Version23.0
Bundle IDcom.automattic.alpha.woocommerce
Commit1a11ed7
Installation URL5ftmvtnpm8fjo
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

@joshheald joshheald self-assigned this Aug 11, 2025
Copy link
Contributor

@joshheald joshheald left a comment

Choose a reason for hiding this comment

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

Works well, and it's an improvement to the log message IMO. Thanks!

I've tested on an iPadOS 17.7.2 physical iPad, and an iPadOS 26.0 simulator.

@staskus staskus enabled auto-merge August 11, 2025 10:29
@staskus staskus merged commit 3e89dae into trunk Aug 11, 2025
14 checks passed
@staskus staskus deleted the woomob-660-ios-26-exc_breakpoint-signalcompressionsignalencoderswift261 branch August 11, 2025 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: mobile payments Related to mobile payments / card present payments / Woo Payments. feature: POS type: crash The worst kind of bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants