ReviewOS

craft-native/craft

fix(ios): Swift-only actions that wait on a framework callback have no deadline

#224
Closed glennmichael123 opened this 10 days ago ·
10 days ago

Companion to the Zig list in #223, and cross-referenced to #211. These actions are answered only by Swift, whether or not the Zig runtime is linked, so a Zig deadline never reaches them. Each one's only answer comes from a framework callback that no person is waiting on.

actionwhere it waits in CraftApp.swift
checkPermission('notifications')UNUserNotificationCenter.getNotificationSettings. Zig returns UnknownAction for this permission, so Swift always serves it
registerPush, after the grantdidRegisterForRemoteNotificationsWithDeviceToken / didFail…. A second call also overwrites the single pendingPushCallbackId, so the first promise never settles
getProductsawait Product.products(for:)
updateLiveActivity, endLiveActivityawait activity.update / await activity.end

The pattern

#211's Swift half is a [UUID: DispatchWorkItem] keyed by a token for each call (not by callbackId, which can be nil and restarts on reload). Both the deadline and the completion run on the main queue and remove the same entry, so only the one that finds it answers. The deadline answers TIMEOUT, and never claims the work happened.

For registerPush, the overwrite needs fixing whatever happens to the deadline: reject the displaced call the way getCurrentPosition rejects a replaced request.

Sign in to comment on this issue.