-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
shell: Use the "load" event instead of polling to catch ready frames #21061
shell: Use the "load" event instead of polling to catch ready frames #21061
Conversation
mvollmer
commented
Oct 1, 2024
•
edited
Loading
edited
- TestPages flakes with Firefox
73cab72
to
b919586
Compare
28f9e82
to
2d23583
Compare
The two What they do:
Step 2) might simulate the code inside the iframe changing its own location, but that is not something Cockpit supports beyond changing the hash. Both the old and new Shell will just react to the "load" event on the iframe, run their hash tracking stuff, and then put the correct "src" attribute back. The old Shell would run its polling loop, but the new Shell just brings the DOM into sync with its own reality. So, without knowing what testFrameReload is actually testing, I don't know whether the new Shell broke something. |
FTR, I'm afraid I don't know what that
It seems to me that we should test this using the "Active pages" killer in the session menu (with Alt) and then loading it back from the menu -- otherwise it's just internal hackery and meaningless IMHO. |
Hmm, there is also the "Reload this frame" action in the browser menu. I wonder if we survive that. 37aedec is worried about the router, and that a page needs to be unregistered when it is reloaded. (so that the channels open for the previous incarnation of the frame are closed,) I think this happens now via the "unload" event that the router listens to. I'll experiment a bit with "Reload this frame" as well. |
Alright, reloading the frame would correctly unregister it from the router, but when it was loaded, we didn't do the necessary setup, like attaching the event handler for the idle timeout. So let's attach our own permanent "load" and "unload" handlers and do the setup on every load. There is now also a teardown that unsets the ready flag, which helps with avoiding flicker in dark mode. The testFrameReload tests should not touch the data-ready attribute, I'd say, but should instead check that open channels are closed properly. It would be best to reload the frame explicitly instead of messing with the "src" attribute. I would guess bidi can do that, right? |
@mvollmer: Yes, bidi has a reload() API, we already use it in testlib.py's |
2d23583
to
7455a9e
Compare
I tried, but it seems to reload everything always. Also, I got |
Let's get this in as a followup to #21012. |
341b8d4
to
06995fd
Compare
if (frame.ready) { | ||
frame.ready = false; | ||
state.update(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. they should. I'll check.
Just to clarify: step 2 is very likely only supposed to reload the frame without changing the url, not simulate loading a different url inside the frame. |
And only show the frame once it is loaded. This side-steps the problems with showing a white not-yet-loaded iframe in dark mode. The two testFrameReload tests have been changed to more directly check for what we want: The channels open by the previous incarnation of the frame should be closed when it is reloaded. This also means we don't need the "data-ready" attribute anymore in the DOM.
6e6015b
to
196edc0
Compare
if (frame.ready) { | ||
frame.ready = false; | ||
state.update(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be fixed. We need to add the "unload" handler once every "load" event, since it sits on the contentWindow, which is a different one on every load.
This might remove a flake, and it also removed the OSTree special case, somehow.
196edc0
to
0bdc149
Compare
TestPages.testBasic and TestPages.testHistory are flaking pretty consistently on Firefox now. I'll check this out more. |
Also testMenuSearch. I hope we have only uncovered existing races in the tests. |
Perhaps just skip the test (or that part of the test) on Firefox? |
Same fix as for testBasic also works for testMenuSearch: https://cockpit-logs.us-east-1.linodeobjects.com/pull-21061-0c1cea44-20241016-075719-fedora-40-firefox-expensive/log.html |
Nah, it's a good test for tricky business (getting browser history right) and we really should run it on Firefox. It does reach the end successfully. There is just the occasional oops. We could allow oopses, but that would be too broad. We could invent machinery that ala allow_journal_messages, that allows specific oopses, but this here really is a bug in Firefox that might conceivably be fixed some day. |
0c1cea4
to
6ffdfcd
Compare
The naughty landed -- so a retry of the amplified run should go green now, with the naughty hitting? |
test/verify/check-pages
Outdated
b.go("/system") | ||
b.enter_page("/system") | ||
b.switch_to_top() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is really weird -- can you please mark this as # HACK
? its really not obvious why this happens. open_lang_modal() already does a switch_to_top()
, and that is an entirely trivial operation (just setting an internal variable), so that line should go. More importantly, it's not clear why the language switcher would work from one frame but not the other one. Is that some "mouse click gets blocked by some element" situation again? how does it look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point about switch_to_top
, I'll remove that.
The problem was doing the go("/system")
after changing the language. It sometimes didn't have any effect. Changing the language always works.
I can debug this further, but I could never reproduce it locally, so that's going to be a bit of a pain...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Ahh, I think I know. The router starts working a bit later since the shell rewrite, because I though there can be no messages before we create iframes. But tests actually send messages to implement b.go
, and if they come to early after a reload, we'll miss them. So let's wait for the shell to be fully loaded again before navigating.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removes a flake.
6ffdfcd
to
e8608f3
Compare
e8608f3
to
f21b647
Compare
Moved to #21125 |
In principle yes, but the naughty pattern is too tight and doesn't trigger on a test named testHistory6... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A work of art! 🙇
Hmm, TestPages.testMenuSearch on ubuntu also flakes. Some service error show up later in the test although they have been cleared at the beginning. Let's fix that as well... |
It's fwupd-refresh.service that runs on a timer. It probly fails because it has no network connection. Let's just reset the failure state immediately before the screenshot, that should make the time window impossible small to hit.... |
On ubuntu-stable, the fwupd-refresh service would otherwise sometimes manage to fail between resetting the failures at the start of the test and the time we take the screenshot.
Thanks for tracking that down. That also seems fine to disable in test/vm.install. |
Yeah, but then it's a different service that fails later on... |
Ah, you meant a global |
36bf06f
to
54a3ccd
Compare
Oh no, the naughty pattern doesn't match, probably because the text it matches against doesn't actually contain the |
Luckily @martinpitt figured it out. Extra whitespace, fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship it! 🚀