Page MenuHomePhabricator

TypeError: undefined is not an object (evaluating 'el.classList')
Open, HighPublicPRODUCTION ERROR

Description

Error
normalized_message
TypeError: undefined is not an object (evaluating 'el.classList')
exception.trace
	at addClass https://fr.m.wikipedia.org/w/load.php?lang=fr&modules=ext.kartographer.dialog%7Cmapbox%7Coojs-ui.styles.icons-interactions&skin=minerva&version=zdh9r:78:333
at panBy https://fr.m.wikipedia.org/w/load.php?lang=fr&modules=ext.kartographer.dialog%7Cmapbox%7Coojs-ui.styles.icons-interactions&skin=minerva&version=zdh9r:92:284
at https://fr.m.wikipedia.org/w/load.php?lang=fr&modules=ext.kartographer.dialog%7Cmapbox%7Coojs-ui.styles.icons-interactions&skin=minerva&version=zdh9r:228:282
Impact

~144 in last 12 hours
https://logstash.wikimedia.org/goto/022770935bab7bbe2c86aaf39a9e66d6

Notes

seems to affect mobile only

Event Timeline

Jdlrobson added subscribers: awight, Jdlrobson.

Error started on 9th December 2021. It's one of our highest errors. @awight could this relate to your recent changes there?

Mapbox was updated early in november.. but I think that train'ed to production before the hiatus? not sure...

This is now our highest error by volume.

Hey all, is this an Unstewarded-production-error ? If not, could someone who knows this code please please investigate this issue?

This appears to be a bug in the Leaflet library. Specifically here: https://github.com/Leaflet/Leaflet/blob/main/src/map/Map.js#L343. For some reason this._mapPane is not yet set, or already deleted. We do have a few calls to Map.remove() in our code that might be related to this issue, but I can't see an obvious problem with that.

There is a very, very similar issue already reported upstream, but closed with no action: https://github.com/Leaflet/Leaflet/issues/6859.

This is our highest volume bug at the moment (when you exclude browser extensions). Is there anyway we can workaround this or at least make sure it is not logged?

Change 894734 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Kartographer@master] Use OOUI getHoldProcess to disable dragging as early as possible

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

I was finally able to reproduce the issue a little better:

  • Open any map in fullscreen.
  • Use the mouse, press the left mouse button, and start dragging the map around. Don't release the left mouse button.
  • Press Esc. Note how the fullscreen map doesn't instantly close but fades out with a little animation.
  • Keep holding the mouse button and move the mouse while the fade-out is in progress.

Peek 2023-03-06 22-28.gif (389×571 px, 196 KB)

What happens:

  • Closing the fullscreen map ultimately triggers the getTeardownProcess in modules/dialog/dialog.js.
  • This calls map.remove() (here).
  • This is a method in the mapbox lib that does all the right things, including delete this._mapPane (here).
  • But dragging the mouse started a call to map.panBy that's delayed via requestAnimFrame (here). This can't handle a missing this._mapPane.

A partial solution I found is to patch the mapbox lib the same way it's already done in other functions in the lib:

panBy: function (offset, options) {
    // Fail-safe when this is called via requestAnimFrame() but the map is gone by now
    if ( !this._mapPane ) {
        return this;
    }

Unfortunately this hack alone doesn't solve the issue. Now I get the next error: "TypeError: Cannot set properties of undefined (setting '_leaflet_pos')". This sounds like T297848 but comes form another spot in the library.

What we really need to do is to make sure this drag event can't even start. I might have found a way to do this, see https://gerrit.wikimedia.org/r/894734.

Change 894734 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Use OOUI getHoldProcess to disable dragging as early as possible

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

Unfortunately the above patch doesn't seem to have had any major impact on the logs. This issue is still occurring... primarily in mobile. :(
https://logstash.wikimedia.org/goto/83cc285199ed00b1efbd849c78c9095d

Change 898681 had a related patch set uploaded (by Thiemo Kreuz (WMDE); author: Thiemo Kreuz (WMDE)):

[mediawiki/extensions/Kartographer@master] Disable all interaction right before fullscreen map closes

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

I can see at least one thing. Quite a bunch of current stack traces mentions _performZoom, which is called from _onWheelScroll, which belongs to ScrollWheelZoom. We intentionally didn't add this in https://gerrit.wikimedia.org/r/894734. I made another patch.

Change 898681 merged by jenkins-bot:

[mediawiki/extensions/Kartographer@master] Disable all interaction right before fullscreen map closes

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

When I filter the client errors on logstash a bit more aggressively and exclude stack traces that mention unrelated things like IntersectionObserver, updateTocLocation (that's Desktop Improvements (Vector 2022), by the way), as well as handleClassesToggle/handleTitleChange (that's SDAW-SearchVue) I see a steep drop from about 20 to 2 events/day on March 10th. This correlates with when 1.40.0-wmf.26 was deployed, which is the first version with our first patch. The second patch was only deployed a few hours ago. I can't find enough data points to say anything about that at the moment.

Your URL doesn't work for me, but https://logstash.wikimedia.org/goto/4202bbf8a36cf222b70af8bacff515c4 is the URL I'm using here. I'm filtering by stack trace at panBy and I'm not seeing any drop and the error is still present in 1.41.0-wmf.1.
{F36925994}

Ah, I see. I was searching for "classList". When I search for "el.classList" I find much more.

It's apparently only Safari (various versions) on Mac OS X, and almost exclusively on mobile domains. Unfortunately the stack traces are not helpful. I don't know how to proceed from here. It might even be related to Desktop Improvements (Vector 2022). Maybe https://gerrit.wikimedia.org/r/902673 helps. We will see.

Ah, I see. I was searching for "classList". When I search for "el.classList" I find much more.

It's apparently only Safari (various versions) on Mac OS X, and almost exclusively on mobile domains. Unfortunately the stack traces are not helpful. I don't know how to proceed from here. It might even be related to Desktop Improvements (Vector 2022). Maybe https://gerrit.wikimedia.org/r/902673 helps. We will see.

I don't think desktop improvements is related, given this is exclusively mobile domains and desktop improvements is Vector 2022 which is exclusively desktop domain. It does seem to mostly occur on mobile Safari (iPhone) according to the browser user agent, but it does seem possible to replicate in Mac OS X so hopefully that will lead to us being able to replicate it. Thanks for attempting to fix this regardless, it's appreciated!