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

Lag during render when using cross sub-array #8766

Open
lalmat opened this issue Sep 5, 2018 · 3 comments
Open

Lag during render when using cross sub-array #8766

lalmat opened this issue Sep 5, 2018 · 3 comments

Comments

@lalmat
Copy link

lalmat commented Sep 5, 2018

Version

2.5.17

Reproduction link

https://jsfiddle.net/Lalmat/eywraw8t/336389/

Steps to reproduce

I've isolated the bug here : https://jsfiddle.net/Lalmat/eywraw8t/336389/

To reproduce :

  1. Try to hide/show the hello world message, the redraw is instant
  2. Use the load data button
  3. Try to hide/show the hello world message, there's a lag that is fully dependant of you CPU velocity.

It seems that there's a setTimeout inside vue that cause this lag

What is expected?

Instant redraw

What is actually happening?

Lag during redraw depending of computer CPU


I use cross arrays to avoid using a toggle function. I'm completely aware that this code is kind of tricky but I can't understand why there's a lag...

This is why I follow this to experts :)

@fnlctrl
Copy link
Member

fnlctrl commented Sep 5, 2018

It's not a setTimeout. Performance timeline shows massive dependArray calls, which is caused by array access in v-model

<input type="checkbox" v-model="bat.lines[line.id].checked">

image

I'm not familiar with the code but perhaps this PR would fix this.

A quick workaround (or maybe the correct way in your case) is to use an object for bat.lines since you're using it as a hash map(direct access by key) rather than an array. See https://jsfiddle.net/eywraw8t/336702/

@lalmat
Copy link
Author

lalmat commented Sep 6, 2018

Working, thank you !

@jamesalanfinnigan
Copy link

Another solution that worked for me with one-way binding and a click event handler.

<input type="checkbox" :value="bat.lines[line.id].checked" @click="bat.lines[line.id].checked = !bat.lines[line.id].checked">

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