Leaflet does not work in WebEngine after JavaFX 17

I have entered this into the JDK bug database because there seems to be a more general issue here. See: https://bugs.openjdk.java.net/browse/JDK-8276859 This is also not the only report about such an issue. See also: After Java update to the version 1.8.0_301 JavaFX WebView with Leaflet.Draw.Circle, Leaflet.Edit.Circle does not work as well as OSM is not draggable


It's nice to see that there are more of us looking into this.

I did some deeper investigation and was able to pinpoint the problem which consequently lead me to a workaround/hack which makes dragging of Leaflet map to work fine in WebKit (Java FX 17).

Findings:

  1. This is definitely regression as dragging of Leaflet map works fine with JavaFX releases prior to 17. So as @José pointed out it's most probably related to WebKit 610.2 upgrade (JDK-8259635).

  2. It seems to be related to PointerEvent which seems to not be properly generated in the case of Java FX 17. Following example outputs 1 when dragging with the mouse button down. But it outputs 0 in the case of WebView/WebKit inside Java FX 17. Note that e.buttons value is properly set to 1 in JavaFX WebView/WebKit versions prior to Java FX 17.

<!doctype html>
<body style="height: 200px">
  <p>Click and drag & observe the console output</p>  

  <script>
    var onMove = function (e) {      
      console.log("e.buttons: " + e.buttons);
    }
    
    var body = document.getElementsByTagName('body')[0];
    document.addEventListener("pointermove", onMove, false);
  </script>
</body>
  1. Based on the finding no. 2 I was able to identify the JS code which prevent the Leaflet map from moving (while being dragged). In Leaflet 1.7.1. it's actually this if expression which consequently causes map to not be moved (because PointerEvent.buttons is wrongfully set to 0 by Java FX 17): https://github.com/Leaflet/Leaflet/blob/bd88f73e8ddb90eb945a28bc1de9eb07f7386118/src/dom/DomEvent.Pointer.js#L104

  2. I've already reported this through the Oracle bug report system (JDK-8278150). The issue was "mistakenly" closed - I've already provided them with the info explained in this answer so they will hopefully re-open it or tackle it under JDK-8276859.

Workaround (Leaflet 1.7.1):

Workaround/hack to make Leaflet map work again:

Comment out the if expressions at: https://github.com/Leaflet/Leaflet/blob/bd88f73e8ddb90eb945a28bc1de9eb07f7386118/src/dom/DomEvent.Pointer.js#L104

This makes the Leaftlet map to move properly while being dragged in the Java FX 17 WebView - but please consider this more like a hack to make it work again as this was not tested out thoroughly...

Update 1

This issue seems to be gone with the latest master branch of Leaflet despite regression in JavaFX WebView/WebKit remains (can anyone please confirm this?).

Update 2

As stated by @mipa, the underlying issue was fixed in 8u291 and openjfx17. More info available at: http://bugs.openjdk.java.net/browse/JDK-8278759