Page MenuHomePhabricator

Infobox not always loading correctly on Special:Contributions; possible race-condition
Closed, ResolvedPublic3 Estimated Story PointsBUG REPORT

Description

What is the problem?

Sometimes when loading Special:Contributions, the IPInfo infobox does not load correctly. See below screen capture.

You notice that the infobox, although expanded, does not appear. Then, when I collapse the infobox it adds the IPInfo to the DOM (but it is hidden). It also sends an API request to API:Options saving the state of the infobox as expanded (i.e. {"change": "ipinfo-infobox-expanded=1"}).

I have also seen a similar thing happen when the saved state of the infobox is collapsed. After the page loads, when I expand the infobox it does not load the info.

So far, this happens for me more often on a slow internet connection (you can simulate this in Firefox and Chrome devtools). For example, the above screen capture was done on Firefox simulating a "Regular 3G" connection.

It can also happen when you refresh the page twice in quick succession.

It might be because changes in the initialisation logic made here have made it more vulnerable to race-conditions and to the wrong logic being followed. I tried to reproduce this bug before that patch, but was unsuccessful.

Steps to reproduce problem
  1. Login as a user with IPInfo rights (and set all their preferences etc.)
  2. Go to Special:Contributions page of an IP
  3. Expand the IPInfo infobox
  4. Keep refreshing the page until the infobox does not load (it might help to artificially throttle your connection, as I mentioned above)

Expected behavior: IPInfo infobox shows every time
Observed behavior: IPInfo infobox sometimes fails to load

Environment

Browser: Firefox 91, Chromium 87
Wiki(s): local docker IP Info 0.0.0 (fe1ba73) 07:15, 21 February 2022.

Event Timeline

Pinging @Prtksxna - we were just discussing this issue...

TThoabala set the point value for this task to 3.Feb 28 2022, 5:44 PM
TThoabala subscribed.

From the patch mentioned above isLoaded might not be set properly.

Change 769470 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/IPInfo@master] Add dependency on mediawiki.htmlform for CollapsibleFieldsetLayout

https://gerrit.wikimedia.org/r/769470

The problem was here:

...
} else if ( $( '.ext-ipinfo-panel-layout .mw-collapsible-toggle' ).attr( 'aria-expanded' ) === 'true' ) {
	// Only auto-load ip info if infobox is expanded on-load
	timerStart = mw.now();
	loadIpInfo( ip );
} else {
...

The aria-expanded attribute is added by jquery.makeCollapsible, which is loaded via htmlform.js, which is loaded via the mediawiki.htmlform module.

The mediawiki.htmlform module is always loaded on Special:Contributions, but not necessarily before the above code runs, because it is not an explicit dependency. The fix is to add it as a dependency in extension.json.

Change 769470 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Add dependency on mediawiki.htmlform for CollapsibleFieldsetLayout

https://gerrit.wikimedia.org/r/769470

@Tchanders I can still reproduce this bug, but less often than before.

On Firefox 91 and Chromium 87 locally. Also on Firefox 98 and Safari 15 on Saucelabs (so it is not just a problem with my local machine).

When this occurs, I notice that the div.mw-collapsible-content element is empty, whereas before it was just hidden.

I followed the reproduction steps in the description. At step 4, you could also try:

  • Opening Special:Contributions in a new tab but don't immediately go to it (you could try opening multiple Special:Contributions tabs one after the other)
  • Loading Special:Contributions for the first time
  • Reopening a Special:Contributions tab you just closed (ctrl+shift+t)

Perhaps @imaigwilo could see if she can reproduce as well.

Change 771385 had a related patch set uploaded (by Tchanders; author: Tchanders):

[mediawiki/extensions/IPInfo@master] Ensure the collapsible panel is made collabpsible before infobox/init.js runs

https://gerrit.wikimedia.org/r/771385

Thanks @dom_walden - we also needed to ensure the collapsible functionality actually runs first; added in the new patch.

Thanks @dom_walden - we also needed to ensure the collapsible functionality actually runs first; added in the new patch.

Thanks. I've just noticed that I cannot get the infobox to expand at all on Chrome or Safari. The patch above appears to fix this. We should probably prioritise the code review on this, so it can be merged before we release to testwiki (although we have 4 trains next week). @TThoabala @AGueyte @wikitrent @STran

Thanks @dom_walden - we also needed to ensure the collapsible functionality actually runs first; added in the new patch.

Thanks. I've just noticed that I cannot get the infobox to expand at all on Chrome or Safari. The patch above appears to fix this. We should probably prioritise the code review on this, so it can be merged before we release to testwiki (although we have 4 trains next week). @TThoabala @AGueyte @wikitrent @STran

Actually, the infobox is only broken on Minerva (and for all browsers). So it is probably not as urgent. Just letting @Niharika know.

Change 771385 merged by jenkins-bot:

[mediawiki/extensions/IPInfo@master] Check class of collapsible panel in infobox init script

https://gerrit.wikimedia.org/r/771385

It is now loading for me consistently, I did not have any race condition. Tested on Safari, Chrome, and FF

@imaigwilo I think it might be a good idea to also test this on different skins (Minerva, Monobook, Timeless). For example, Minerva seemed to be affected by this bug more consistently than the other skins.

I believe you should also be able to test this on testwiki, if you want.

Yes Minerva skin does not expand consistently, the other skins where fine with no issue
Example link not loading with Minerva skin: https://test.wikipedia.org/wiki/Special:Contributions/184.160.70.92

Screen Shot 2022-03-29 at 10.38.16 PM.png (1×2 px, 331 KB)

It some how expanded here, but will not collapse, when I click serval times: https://test.wikipedia.org/wiki/Special:Contributions/184.160.70.92?openInfobox=true
Screen Shot 2022-03-29 at 10.41.23 PM.png (1×2 px, 397 KB)

Yes Minerva skin does not expand consistently, the other skins where fine with no issue
Example link not loading with Minerva skin: https://test.wikipedia.org/wiki/Special:Contributions/184.160.70.92

Screen Shot 2022-03-29 at 10.38.16 PM.png (1×2 px, 331 KB)

It some how expanded here, but will not collapse, when I click serval times: https://test.wikipedia.org/wiki/Special:Contributions/184.160.70.92?openInfobox=true
Screen Shot 2022-03-29 at 10.41.23 PM.png (1×2 px, 397 KB)

Ooh, that's interesting, thanks @imaigwilo! (I didn't know about openInfobox=true before.)

I have also observed that occasionally the API request to save the current state of the infobox expanded/collapsed state is incorrect. I.e. when I expand the infobox it sends ipinfo-infobox-expanded=0 and when I collapse it sends ipinfo-infobox-expanded=1. (This happens on the Vector skin, and probably other skins, I haven't checked.) I have not been able to reproduce this bug in the parent commit (39206a1ad884c96daa4534ea613ccfde011eebb2), although by its nature it is very intermittent so it might have happened before.

@Tchanders I don't know what you want to do. Would you like separate bugs or continue working on this bug?

I also am concerned that there may be more bugs in this area that we haven't found yet. We might need more time to test this.

@Tchanders I don't know what you want to do. Would you like separate bugs or continue working on this bug?

Thanks @dom_walden. Would it be possible to file two separate tasks, one about the problem in Minerva and the other about the incorrect API query? They each need a bit of a closer look. I suspect we'll de-prioritise the Minerva one until we're ready to support mobile.

@Tchanders I don't know what you want to do. Would you like separate bugs or continue working on this bug?

Thanks @dom_walden. Would it be possible to file two separate tasks, one about the problem in Minerva and the other about the incorrect API query? They each need a bit of a closer look. I suspect we'll de-prioritise the Minerva one until we're ready to support mobile.

I have raised T305529 for the Minerva bug.

For the other bug, I am not sure it is not just a symptom of this bug, which I have been able to reproduce on Firefox (maybe 1 times out of 10).

On Firefox, when the saved state of the Infobox is collapsed:

  • I can reproduce this bug (infobox not loading correctly)
    • I have reproduced this locally on Firefox 91 and also on a virtualised Windows 10 Firefox 98 (just in case there was something weird about my local system)
  • At the same time, I also get the API bug (as far as I have been paying attention, they have always coincided)

When the saved state is expanded:

  • I cannot reproduce this bug (the infobox always loads correctly)
  • I can reproduce the API bug

(I just tried for ~15 mins to reproduce any of the above behaviour on Chromium, but was unsuccessful.)

Would you still like a separate bug? Or continue working on this bug based on my hypothesis about them being symptoms of the same issue?

I have raised T305529 for the Minerva bug.

Thanks.

For the other bug, I am not sure it is not just a symptom of this bug, which I have been able to reproduce on Firefox (maybe 1 times out of 10).

Now I've looked into this separately from the Minerva issue, I can see that it's a new bug - related to this one, but a separate cause, so I've filed it separately: T305650