html-next / vertical-collection

Infinite Scroll and Occlusion at > 60FPS
https://html-next.github.io/vertical-collection/
MIT License
176 stars 77 forks source link

Application test times out when two vertical collections share a containerSelector #320

Open steveszc opened 4 years ago

steveszc commented 4 years ago

Minimal reproduction repo: https://github.com/steveszc/vertical-collection-shared-container-reproduction

When a route template contains two vertical-collections that share a common containerSelector (ex a scrollable body) a test that visits that route will timeout on the await visit(). The vertical-collections work as expected when using the app, however.

steveszc commented 4 years ago

Maybe related: https://github.com/html-next/ember-raf-scheduler/issues/5

steveszc commented 4 years ago

Related: https://github.com/html-next/vertical-collection/issues/197

steveszc commented 4 years ago

I spent some time debugging this with some teammates. We were able to identify the root cause of this issue, which is a faulty piece of conditional logic inside the scroll handler util. https://github.com/html-next/vertical-collection/blob/master/addon/-private/data-view/utils/scroll-handler.js#L53

When passive event listeners are supported, and two vertical-collection instances share the same container element, then the first vc instance adds a passive event listener, but the second vc instance starts polling for the event.

We only want to add the event listener once and want to avoid polling altogether when passive event listeners are supported.

Starting the polling pushed an extra job into the ember-raf-scheduler which was never removed. This caused ember-raf-scheduler's testWaiter to hang indefinitely.

I'll plan to submit a PR with the fix and a test in the next week or two.

MariannaAtPlay commented 2 years ago

Hello! Are there any plans to fix this issue? We are running into this as well! Thank you @steveszc for figuring out the root cause.