[minor] [bugfix]: Fix Swift 6 actor-isolation crash for all public callback typedefs#2920
Open
kaisong1990 wants to merge 4 commits into
Open
[minor] [bugfix]: Fix Swift 6 actor-isolation crash for all public callback typedefs#2920kaisong1990 wants to merge 4 commits into
kaisong1990 wants to merge 4 commits into
Conversation
Mark MSALLogCallback and MSIDLogCallback with NS_SWIFT_SENDABLE and NS_SWIFT_NONISOLATED to fix Swift 6 strict concurrency crash when log callbacks are invoked from a non-main-actor context. Update IdentityCore submodule with matching MSIDLogCallback fix.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates MSAL’s public logging callback type to improve Swift 6 strict concurrency interoperability (avoiding crashes when callbacks are invoked off the main actor), and it also updates the IdentityCore submodule to pick up the corresponding MSIDLogCallback fix.
Changes:
- Annotate
MSALLogCallbackwithNS_SWIFT_SENDABLEandNS_SWIFT_NONISOLATEDfor Swift concurrency compatibility. - (Per PR description) Update
IdentityCoresubmodule reference to include the matchingMSIDLogCallbackchange.
…edefs Annotate all remaining public block typedefs in MSALDefinitions.h with NS_SWIFT_SENDABLE and NS_SWIFT_NONISOLATED to prevent Swift 6 runtime actor-isolation crashes when callbacks are invoked on background threads. Affected typedefs: - MSALCompletionBlock (acquireToken/acquireTokenSilent) - MSALAccountsCompletionBlock - MSALCurrentAccountCompletionBlock - MSALSignoutCompletionBlock - MSALDeviceInformationCompletionBlock - MSALWPJMetaDataCompletionBlock - MSALTelemetryCallback MSALLogCallback was already annotated in the previous commit. Fixes: #2474 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add entry for NS_SWIFT_SENDABLE NS_SWIFT_NONISOLATED annotations on all public block typedefs to fix Swift 6 runtime crashes (#2474).
antrix1989
approved these changes
Apr 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Title Format
Required Format:
[Keyword1] [Keyword2]: Descriptionmajor,minor, orpatch(case-insensitive)feature,bugfix,engg, ortests(case-insensitive)Proposed changes
This pull request annotates all public block typedefs in
MSALDefinitions.hwithNS_SWIFT_SENDABLEandNS_SWIFT_NONISOLATEDto fix Swift 6 runtime crashes (EXC_BREAKPOINT/SIGTRAP) caused by actor-isolation checks when callbacks are invoked on background threads.Root cause
In Swift 6, closures defined in
@MainActorcontexts (e.g., SwiftUIAppstructs) inherit@MainActorisolation. When MSAL invokes these callbacks on background threads (logger serial queue, network completion, etc.), the Swift 6 runtime asserts the closure is on the main thread and crashes withdispatch_assert_queue_fail.Changes
MSALDefinitions.h: AddedNS_SWIFT_SENDABLE NS_SWIFT_NONISOLATEDto all 8 public block typedefs:MSALCompletionBlock(acquireToken/acquireTokenSilent)MSALAccountsCompletionBlockMSALCurrentAccountCompletionBlockMSALSignoutCompletionBlockMSALDeviceInformationCompletionBlockMSALWPJMetaDataCompletionBlockMSALLogCallbackMSALTelemetryCallbackMSIDLogCallbackannotation (PR [minor] [bugfix]: fix crash in Swift 6 microsoft-authentication-library-common-for-objc#1761)Impact
NS_SWIFT_SENDABLEandNS_SWIFT_NONISOLATEDare compiler import hints that Swift 5 effectively ignores@Sendableannotation may produce new compile-time warnings for callers capturing non-Sendable state, but this is preferable to runtime crashesFixes #2474
Type of change
Risk