Skip to content

[web] flaky tests on inactive tabs: css transitions, requestAnimationFrame #53985

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

Open
sigmundch opened this issue Nov 8, 2023 · 3 comments
Open
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-libraries Issues impacting dart:html, etc., libraries

Comments

@sigmundch
Copy link
Member

A few lib/html and co19 tests are testing CSS transitions, and these tests currently timeout or flake on Chrome.

See for example lib/html/transition_event_test: https://dart-current-results.web.app/#/filter=lib/html/transition_event_test

This test passes consistently in FF and Safari, but flakes on dart2js-linux-chrome nearly 90% of the time.

It appears that, like setTimeout, Chrome ignores CSS transitions on background tabs. As a simple repro, you can create a small JS program that:

  • creates an element with a css transition (like the one in transition_event_test)
  • uses setTimeout to start the transition after a delay, this gives you time to switch tabs and put it in the background before triggering the CSS transition
  • use a few additional setTimeout to log JS activity every few seconds.
  • add a listener for transitionrun, transitionstart, and transitionend events to log when they occur

What I observe is that all the JS timers complete and log data on the console, but the transition events do not trigger until after I reopen the tab and bring it in the foreground.

This leads me to believe we can't run these tests unless:

  • there a flag similar to what was recently discovered for timers that we can apply here to allow CSS transitions in background tabs
  • we make sure tabs are always active instead (e.g. open multiple windows, instead of opening multiple tabs?)

@whesse - are any of these possible?
@srujzs - should we just delete these tests?

@sigmundch sigmundch added web-libraries Issues impacting dart:html, etc., libraries area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. labels Nov 8, 2023
@sigmundch
Copy link
Member Author

I'm also seeing a similar behavior with requestAnimationFrame API calls

@sigmundch sigmundch changed the title [web] css transitions cause flake tests [web] flaky tests on inactive tabs: css transitions, requestAnimationFrame Nov 8, 2023
@srujzs
Copy link
Contributor

srujzs commented Nov 9, 2023

lib/html/transition_event_test mostly just uses native APIs and the conversion to a Stream. The latter conversion is tested in other places, so I think there isn't much value to testing the APIs that are within that test.

lib/html/request_animation_frame_test is a bit weird. There's one call to _ensureRequestAnimationFrame which does vendor-specific implementation checking, and then replaces requestAnimationFrame with a callback wrapped in a timeout?

@sigmundch
Copy link
Member Author

lib/html/transition_event_test mostly just uses native APIs and the conversion to a Stream. The latter conversion is tested in other places, so I think there isn't much value to testing the APIs that are within that test.

agree

lib/html/request_animation_frame_test is a bit weird. There's one call to _ensureRequestAnimationFrame which does vendor-specific implementation checking, and then replaces requestAnimationFrame with a callback wrapped in a timeout?

Technically it is checking for whether it is implemented, and if not, it adds a polyfill for this feature. I believe we never hit the case of the polyfill.

Most of the test is doing 1 or 2 calls to requestAnimationFrame and testing whether the callback is called as expected or whether cancelling the request works as expected. All of this is native behavior, and nothing specific about Dart IMO.

FWIW - I just sent out https://dart-review.googlesource.com/c/sdk/+/335030 to start skipping these tests in Chrome for now.

copybara-service bot pushed a commit that referenced this issue Nov 10, 2023
All tests skipped here are flaking or timing out. Most of them fail for
a common reason tracked in
#53985: Chrome inactive tabs do
not run behave the same as active tabs. This means that interactions like
css transitions, requestAnimationFrame, and video play don't work as
expected.

This CL skips the tests only on Chrome, but continues to run them in
other browsers where the expectation is met.  If we can in the future
ensure tests are run on an active tab, we can consider reneabling these
tests. That said, the value of this tests was higher when we mantained
Dartium, but these days we may consider deleting them instead.

Change-Id: I9c0ea230fecca16fa008b64c2cf316ccdd0f53e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335030
Reviewed-by: Srujan Gaddam <[email protected]>
Commit-Queue: Sigmund Cherem <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

2 participants