Skip to content

Run AsyncResource completions on EDT in InternalCallback#14

Open
shai-almog wants to merge 1 commit intomasterfrom
codex/investigate-modal-dialog-issue-on-ios
Open

Run AsyncResource completions on EDT in InternalCallback#14
shai-almog wants to merge 1 commit intomasterfrom
codex/investigate-modal-dialog-issue-on-ios

Conversation

@shai-almog
Copy link
Contributor

Motivation

  • Ensure that AsyncResource completion, error and cancel handlers are executed on the UI thread to avoid threading issues.
  • Prevent race conditions where a request may be completed/cancelled multiple times by double-checking isDone.
  • Improve stability of fingerprint/back-end callbacks that interact with UI or UI-tied state.

Description

  • Wrap req.complete, req.error, and req.cancel calls in Display.getInstance().callSerially(...) in InternalCallback so they run on the EDT.
  • Retain an outer !req.isDone() guard and add an inner !req.isDone() check inside the runnable to avoid duplicate terminal actions.
  • Apply the change to requestSuccess, requestError, requestKeyRevokedError, and requestComplete methods.

Testing

  • Ran the project's automated test suite and build, and the tests completed successfully.
  • Verified that the modified callback paths execute without throwing threading-related exceptions in automated runs.
  • No automated tests failed as a result of these changes.

Codex Task

@shai-almog
Copy link
Contributor Author

@shannah can you please review?
This is supposed to address an issue discussed in crisp in which Dialogs won't show on iOS in the callback code because it thinks the app is minimized.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates InternalCallback in the fingerprint module to ensure AsyncResource terminal handlers (complete/error/cancel) execute on Codename One’s EDT, reducing UI-threading hazards in native callback paths.

Changes:

  • Wrap req.complete(...), req.error(...), and req.cancel(...) in Display.getInstance().callSerially(...) so terminal events run on the EDT.
  • Add an inner !req.isDone() guard inside the EDT runnable to prevent duplicate terminal actions when multiple callbacks race.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@shai-almog shai-almog force-pushed the codex/investigate-modal-dialog-issue-on-ios branch from b26f66c to e814443 Compare March 18, 2026 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants