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

GeastureRecognizers are not updated via UpdateIncremental on iOS #11

Open
Dolfik1 opened this issue Aug 10, 2020 · 4 comments
Open

GeastureRecognizers are not updated via UpdateIncremental on iOS #11

Dolfik1 opened this issue Aug 10, 2020 · 4 comments

Comments

@Dolfik1
Copy link

Dolfik1 commented Aug 10, 2020

We have out implementation of CollectionView that frequently uses UpdateIncremental function. I find out that sometimes geastureRecognizers are not updated. There is examle:

let i = ref 0
let view ... =
  incr i
  let a = !i
  View.Label(
    text = string a,
    geastureRecognizers = [
      View.TapGestureRecognizer (fun _ -> printfn "%i" a)
    ]
  )

When I run this example I see different values in UI and stdout. This reproduced only on iOS.

@TimLariviere
Copy link
Member

@Dolfik1 Hmm strange. Fabulous use the exact same logic for all the platforms, so UpdateIncremental shouldn't behave differently between Android and iOS.
Moreover the code that updates gesturesRecognizers is the exact same that updates pretty much everything else, so I don't see why it would behave incorrectly here when everything else works as expected...

It is more likely to be a bug in Xamarin.Forms (well, at least on the iOS implementation) which seems to be a common occurrence according to Google.

Or if you wrote your own CollectionView renderer, it could be an invalid use of UpdateIncremental.

Collections can be tricky to handle because of virtualization, the cells are reused and you need to make sure to keep the correct ViewElements that were used to generate those cells. Otherwise you can end up with mismatch.

Fabulous only compares "previous" and "new" ViewElements to decide what to update in the cell.
If the "previous" ViewElement doesn't exactly match the cell, after calling UpdateIncremental you end up with old data that Fabulous didn't cleared/didn't add, such as GestureRecognizers.

@programmation
Copy link

programmation commented Jan 13, 2021

@TimLariviere I am also experiencing this issue. Taps defined in CollectionView cells fire multiple times after the cell has been recycled. It looks very much as if the event handler for the GestureRecognizer isn't being unhooked when the BindingContext of the cell changes. I seem to recall a fix for something like that in the latest XF 5.0 release. If that's a Xamarin Forms bug, would Fabulous 0.60 be able to work with Xamarin Forms 5.0?

@TimLariviere
Copy link
Member

@programmation Thanks for your report. Would you happen to have a reproduction that you can share?

Regarding XF 5.0, it's not currently possible to use it as there are a bunch of breaking changes. fabulous-dev/Fabulous#836 is aiming to support it.

@programmation
Copy link

@TimLariviere Thanks for the information about XF 5.0. I'll hold off upgrading until it is supported. I'm also trying to put a sample project together to demonstrate the Taps problem in CollectionView cells.

@TimLariviere TimLariviere transferred this issue from fabulous-dev/Fabulous Jan 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants