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

[BUG] UIKit.UIKitThreadAccessException in iOS as canExecute: this.IsValid() doesn't tick in MainThread #70

Closed
gsgou opened this issue Apr 13, 2020 · 4 comments · Fixed by #82
Labels
bug Something isn't working

Comments

@gsgou
Copy link

gsgou commented Apr 13, 2020

Describe the bug
UIKit.UIKitThreadAccessException in iOS as canExecute: this.IsValid() doesn't tick in MainThread

Steps To Reproduce
Bind Command to any Xamarin Forms Button,
SomeCommand = ReactiveCommand.CreateFromObservable(
observable,
canExecute: this.IsValid());
UIKit.UIKitThreadAccessException is thrown

Expected behavior
No thrown UIKit.UIKitThreadAccessException

Environment

  • OS: iOS 13.4
  • Version: Xamarin Forms 4.4.0.991864, Xamarin.iOS 13.16.0.13
  • Working Version: unknown

Additional context
Workaround:

SomeButtonCommand = ReactiveCommand.CreateFromObservable(
    observable,
    canExecute: this.IsValid().ObserveOn(RxApp.MainThreadScheduler));
@gsgou gsgou added the bug Something isn't working label Apr 13, 2020
@open-collective-bot
Copy link

open-collective-bot bot commented Apr 13, 2020

Hey @gsgou 👋,

Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.

https://opencollective.com/reactiveui

PS.: We offer priority support for all financial contributors. Don't forget to add priority label once you start contributing 😄

An advanced, composable, functional reactive model-view-viewmodel framework for all .NET platforms!

@michaelstonis
Copy link

@gsgou this is expected behavior. ReactiveCommands do not explicitly schedule anything on the UI thread. Since CanExecute controls whether a button is enabled/disabled, if you use the BindCommand extension, you need to ensure that the observable that controls CanExecute pushes the notification on the UI thread. Not all commands need to notify on UI thread, so there is no blanket policy to apply or force that on any of the Bind or BindCommand extensions.

@gsgou
Copy link
Author

gsgou commented Apr 13, 2020

@michaelstonis tks a lot, i get it now.
Maybe the Sample could be updated for XF then
and an overload of the IsValid() with a scheduler.

glennawatson pushed a commit that referenced this issue Jul 17, 2020
* Use OAPH instead of ROOC

* Fix error sharing when last property is the same (#60)

* Use the main thread scheduler in this.IsValid (70)

* Switch over from BPV to IPVC (#61)

* Fix duplicating validations

* Bring back the scheduling fix until we ensure it finally works without it

* Fix typo

* Access _validationSource directly

* The scheduling fix is no longer needed

* Don't break ROOC public API

* build(deps): bump PublicApiGenerator from 10.1.0 to 10.2.0

Bumps [PublicApiGenerator](https://github.com/PublicApiGenerator/PublicApiGenerator) from 10.1.0 to 10.2.0.
- [Release notes](https://github.com/PublicApiGenerator/PublicApiGenerator/releases)
- [Commits](PublicApiGenerator/PublicApiGenerator@10.1.0...10.2.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>

* Evil serializable attributes

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants