Skip to content

<ListView> is very slow comparing to NS Core #565

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

Closed
tralves opened this issue Oct 22, 2019 · 11 comments · Fixed by #572
Closed

<ListView> is very slow comparing to NS Core #565

tralves opened this issue Oct 22, 2019 · 11 comments · Fixed by #572

Comments

@tralves
Copy link

tralves commented Oct 22, 2019

Version

2.4.0

Reproduction link

https://play.nativescript.org/?template=play-vue&id=KhyRrD

Platform and OS info

iOS 12/13, Android 8/9, NS Playground

Steps to reproduce

Open the playground https://play.nativescript.org/?template=play-vue&id=KhyRrD.

This project has 2 listviews linked to the same dataset. The one on the right is more complex because it uses different <v-template> and a <GridLayout> for some cells.

Notice that the list view is sluggish, especially the right one.

What is expected?

The ListView should scroll smoothly.

I created an NS Core project with the same dataset and the same UI here: https://play.nativescript.org/?template=play-tsc&id=KkPYYX.

See how smooth it scrolls!

What is actually happening?

On NS-Vue, the ListView scroll is very sluggish compared to the NS Core ListView.

I tested on both Android and iOS devices. The same thing happens: NS Core is smooth, NS-Vue is slow.


The NS-Vue wrapper is doing something that kills the ListView performance. I will start looking at this issue, but I think I'll need the experts on this one.

@shirakaba
Copy link

shirakaba commented Oct 22, 2019

Does NativeScript-Vue implicitly render each ListView cell into a StackLayout/ContentView, or is it a floating tree?

@rigor789
Copy link
Member

We're only rendering whatever is inside the v-template no extra wrapping elements are created. NativeScript requests views through the onViewLoading event, and if we don't have a certain template rendered yet - we create it, otherwise we just patch the existing views with new data.

I'd be curious to see your findings @tralves based on what @bradmartin suggested on Slack.

I wonder if for some reason the patching doesn't work properly in some cases, and re-creates views. I'm also curious to know if this is specific to the latest version, or has it always been like this? I haven't had issues with the LV performance so far. In the app I'm working on, we have around 15 v-templates, and has been working fine, although not that many elements.

@tralves
Copy link
Author

tralves commented Oct 23, 2019

@bradmartin suggestions on slack were not very conclusive. For some reason, the performance of the ListView in the NS-Vue project built on my machine was better than the one from the playground... ¯_(ツ)_/¯. Anyway, the problem is more noticeable on iOS, probably for the dynamic heights.

Has anyone tested the projects in the playground? Do you see the same sluggish scroll?

I also checked the native components tree and they were the same. No problem there.

The next step is to check the patching and re-creation of views.

The LV has always shown these issues since I started the project, almost 1 yr ago...

@tralves
Copy link
Author

tralves commented Oct 24, 2019

@rigor789 I found that at onViewLoading, args.view is always null when we have more than 1 <v-template>s.

So for some reason, the listview is not giving NS-Vue a view to be recycled. I am trying to figure out if the ListView templates are being set correctly, but as far as I can see, they are.

Any ideas?

@tralves
Copy link
Author

tralves commented Oct 25, 2019

It turns out that this is only reproducible on iOS with NS-Vue with multiple templates*:

  • On Android, the views are recycled properly;
  • On NS-Core, the views are recycled properly;
  • With just one template, the views are recycled properly;

I also tested reverting the commit ba4e994, but it didn't fix anything.

So the error must be in the way the templates are passed to the UITableView when using NS-Vue... which doesn't make much sense...

I am searching for more clues on the way the NS creates the native components, but right now I don't have any more ideas...

*- I tested this by attaching itemLoading events to the ListView and loaded events to the components inside the LV templates. The itemLoading triggers when each cell item is rendered but the loaded is only triggered when the actual content is created. On NS-Vue iOS, I see one loaded for each itemLoading, meaning that new components are being created for each cell. On Android/NS-Core, I see a bunch of cells being created at first, but then only itemLoadings.

@shirakaba
Copy link

shirakaba commented Oct 25, 2019

I was curious as to whether the ListView was slow just because of the limits of on-the-fly reconciliation and re-rendering (regardless of UI renderer), so I ported it to React NativeScript.

https://play.nativescript.org/?template=play-react&id=844mww&v=14

But... it scrolls pretty fast on iOS by my eyes 😅

@tralves
Copy link
Author

tralves commented Oct 31, 2019

thank you for the test, @shirakaba! You are right, it works fine on React NS...

(I secretly wished it didn't because Vue is bae and then there would be more people looking into it 😛)

@farfromrefug
Copy link
Contributor

I dont see that issue in my nativescript-collectionview plugin. At least I don't think I do... May be we can try to recreate the example with it and compare. I know I don't handle templates the same way

@tralves
Copy link
Author

tralves commented Nov 5, 2019

I found the issue! (eee the PR above).

For comparison of a before/after, see the updated playground app. The list on the right is patched with this fix.

@tralves
Copy link
Author

tralves commented Nov 5, 2019

Thanks to everyone here helping me turning to the right direction. Peeking at @shirakaba's React implementation was key, though!

@nativescript-vue-bot
Copy link
Collaborator

We are locking this issue because it has been closed for more than 14 days.

If the issue comes up again please open a new issue with additional details.

@nativescript-vue nativescript-vue locked as resolved and limited conversation to collaborators Nov 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

5 participants