-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Description
Version
2.4.2
Reproduction link
https://jsfiddle.net/hgfx55h6/
Steps to reproduce
- Create large array (in my case this array contains more Arrays)
- Prevent extensions with
Object.preventExtensions - Set the array on a Vue viewmodel
What is expected?
Vue's reactivity system should not do anything with this array, and setting this property should have the same runtime as setting a string on the viewmodel (i.e. O(1) )
What is actually happening?
The dependArray function is invoked recursively on the object every time the array is accessed, causing the setting of that property to take linear time. This can occur many times per tick.
This reproducer is very close to my actual scenario. I am building a virtual grid, where I have a large source array, and I compute some start index (normally this would be based on scroll position, in this case I've just added a button to simulate scrolling), and the template renders these rows.
In this jsfiddle, I have Object.preventExtensions()'d the array and never change it. The only thing I am changing is the start index, however doing so has an enormous amount of lag. When I profile this I see:
My issue at its core has nothing to do with reactivity, and is solely about performance. This does not seem like something that should perform this poorly.
