The first hotfix lowered the overall crash rate in a widely used iOS app. But the crash that prompted the release kept showing up in production. The developer investigating it eventually traced the failure to a small disclosure at the bottom of two screens: the app was converting HTML into attributed text without guaranteeing that the conversion ran on the main thread.
A crash rate was not a diagnosis
The crash reports contained a SIGBUS signal and Foundation stack frames associated with rich-text processing, but they did not identify a failing line of Swift. The signal indicated an invalid memory access; it did not establish that an object had been released too early. Neither developers nor QA engineers could consistently reproduce the failure by following the affected workflow.
With about a week initially available to investigate and prepare a fix, the developer checked object lifetimes, reviewed asynchronous screen preparation and made ownership and synchronization more explicit. Those changes improved the code, but the decline in the overall crash rate after release was ambiguous. Changes to object retention or task scheduling could alter how often a timing-sensitive failure occurred without removing its cause. The persistence of the same crash signature mattered more than the aggregate improvement.
One device made competing explanations testable
A QA engineer who used the production app found that she could trigger the crash on her device, sometimes after four or five attempts. A successful run still proved little, but a crash on a modified build could rule out a proposed fix.
The developer supplied roughly nine to ten experimental builds over the investigation. Instead of continuing to revise whichever code looked most suspicious, the developer removed one view or behavior at a time and had QA repeat the same workflow. Six or seven progressively narrowed builds isolated the failure to one file. Further tests narrowed it to the NSMutableAttributedString initializer used to import HTML.
Both affected views displayed legal and explanatory text containing links and phone numbers. Although the disclosures were static, the app received their contents as HTML and converted them for display during asynchronous screen preparation. That path did not guarantee main-thread execution.
Enforcing the requirement at the point of conversion
Apple’s NSAttributedString documentation advises against invoking the importer from a background thread when the document type is HTML. The method may try to synchronize with the main thread, and that attempt can fail and time out. Apple’s broader attributed-string documentation identifies WebKit as responsible for HTML conversion. What looked at the call site like a simple transformation of Data therefore had a threading requirement that the initializer itself did not make apparent.
The developer searched the codebase for HTML-to-attributed-string conversions and routed all existing call sites through a shared helper. In simplified form, it placed the constraint on the operation itself:
enum HTMLAttributedStringRenderer {
@MainActor
static func render(from data: Data) throws -> NSAttributedString {
try NSMutableAttributedString(
data: data,
options: [.documentType: NSAttributedString.DocumentType.html],
documentAttributes: nil
)
}
}
UI code that applied the result was also isolated to MainActor. Networking, decoding and other asynchronous preparation did not need to move with it. The helper gave callers a single way to perform the conversion without having to remember the importer’s threading rule.
The QA engineer repeated the workflow on the same device without seeing the crash. Both affected views and their related features underwent additional testing before the change went into the hotfix branch. After release, the developer reported that the specific crash signature no longer appeared at a statistically meaningful frequency; exact production figures were confidential. Unlike the first hotfix, this one had evidence tied to the failure itself: the device test, a check of every relevant call site and monitoring of the target signature rather than the overall crash rate.