Skip to content

swift-sdk: Platform query methods run blocking FFI calls on the main actor #5145

Closed

Description

@romchornyi

Expected Behavior

A Platform query called from app UI (document search, DPNS availability, contest vote state) does
its network round trip off the main thread, so a slow evonode never freezes the interface.

Current Behavior

The query helpers are declared in @MainActor extension SDK blocks and call synchronous FFI entry
points that block on the network inside Rust (runtime.block_on):

Because the methods are main-actor isolated, a caller cannot move the work off the main thread:
Task.detached { try await sdk.documentList(…) } still hops back to the main actor for the call
(@unchecked Sendable on SDK lets the reference cross, but does not change the method's
isolation). The whole network round trip then runs on the main thread.

Possible Solution

Give these queries a non-main-actor boundary inside the SDK: nonisolated async methods that run
the FFI call on a dedicated executor / background queue, keeping the handle and argument lifetimes
valid for the call and copying and freeing the results there, then return plain Swift values. The
existing main-actor methods can forward to them for source compatibility.

Steps to Reproduce (for bugs)

  1. From a SwiftUI screen, call documentList (or dpnsContestVoteState) against a slow or
    unreachable evonode.
  2. The UI stops responding until the call returns or times out.

Context

Seen in Dash Wallet iOS (dashpay/dashwallet-ios#1141): proof-link lookups in contender details, DPNS
availability checks while typing a username, and contest-state reads. The app cannot fix this on its
side; an app-level detach does not help. Raised by the automated review there.

Your Environment

  • Version used: v4.3-dev @ 67340ad824
  • Environment name and version: SwiftDashSDK (swift-sdk package)
  • Operating System and version: iOS / macOS, any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions