Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Dart invoking medea-jason on non-main thread #197

Merged
merged 15 commits into from
Dec 30, 2024
Merged

Conversation

alexlapa
Copy link
Contributor

@alexlapa alexlapa commented Dec 27, 2024

Revealed in #193

Synopsis

From #193 it seems that at least two different threads call executor task_wake. medea-jason is designed to work in a single threaded environment so that might end bad.

Solution

It was tracked that second thread appears at callback_finalizer and that makes sense since Dart does not guarantee that this callback will only be called on a main thread:

If the object becomes unreachable the callback is invoked with the
the peer as argument. The callback can be executed on any thread, will have
an isolate group, but will not have a current isolate. The callback can only
call Dart_DeletePersistentHandle or Dart_DeleteWeakPersistentHandle.

Checklist

  • Created PR:
    • In draft mode
    • Name contains issue reference
    • Has type and k:: labels applied
    • Has assignee
  • Before review:
    • Documentation is updated (if required)
    • Tests are updated (if required)
    • Changes conform code style
    • CHANGELOG entry is added (if required)
    • FCM (final commit message) is posted or updated
    • Draft mode is removed
  • Review is completed and changes are approved
    • FCM (final commit message) is approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • All temporary labels are removed

@alexlapa alexlapa added enhancement Improvement of existing features or bugfix k::refactor Refactoring, technical debt elimination and other improvements of existing code base platform::android Specific to Android platform platform::ios Specific to iOS platform platform::windows Specific to Windows platform platform::linux Specific to Linux platform platform::macos Specific to macOS platform labels Dec 27, 2024
@alexlapa alexlapa self-assigned this Dec 27, 2024
@alexlapa
Copy link
Contributor Author

alexlapa commented Dec 27, 2024

FCM

Fix `Future`s executor being called from non-main thread on Dart platforms (#197)

Additionally:
- use `std`'s `Waker` instead of custom `RawWaker` implementation
- fix `CLIENT_API_ADDR` config value extracting in the Flutter demo

@alexlapa alexlapa requested a review from evdokimovs December 30, 2024 10:53
@alexlapa alexlapa marked this pull request as ready for review December 30, 2024 10:53
@evdokimovs evdokimovs requested a review from tyranron December 30, 2024 15:12
@tyranron tyranron added the k::design Related to overall design and/or architecture label Dec 30, 2024
@tyranron tyranron enabled auto-merge (squash) December 30, 2024 15:37
@tyranron tyranron merged commit f2fbcc5 into master Dec 30, 2024
51 checks passed
@tyranron tyranron deleted the fix-second-thread branch December 30, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix k::design Related to overall design and/or architecture k::refactor Refactoring, technical debt elimination and other improvements of existing code base platform::android Specific to Android platform platform::ios Specific to iOS platform platform::linux Specific to Linux platform platform::macos Specific to macOS platform platform::windows Specific to Windows platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants