grafana-toolbox / panodata-map-panel

Map Panel for Grafana with improved convenience, robustness and features. Friendly fork of the original Grafana Worldmap Panel. Currently not maintained, but verified to work up to Grafana 9.
https://community.panodata.org/t/grafana-map-panel/121
GNU Affero General Public License v3.0
88 stars 31 forks source link

Conflict with Track Map Panels #80

Open amotl opened 4 years ago

amotl commented 4 years ago

Hi there,

@DmitrySidorow reported about conflicts with Track Map panels at https://github.com/panodata/grafana-map-panel/issues/47#issuecomment-722166379, https://github.com/grafana/worldmap-panel/issues/283 and https://github.com/pR0Ps/grafana-trackmap-panel/issues/43.

I seems to happen with both [1] and [2] and says TypeError: Cannot read property 'x' of undefined.

image

Can you a) confirm that and b) have a look into the developer tools to see if you are able to get more information about this issue, Dmitry?

With kind regards, Andreas.

cc @pR0Ps, @j-or, @CodeFunta, @mourner, @IvanSanchez

[1] https://github.com/pR0Ps/grafana-trackmap-panel [2] https://github.com/alexandrainst/alexandra-trackmap-panel

amotl commented 4 years ago

On the Leaflet issue tracker, I can find https://github.com/Leaflet/Leaflet/issues/1210, https://github.com/Leaflet/Leaflet/issues/2606 and https://github.com/Leaflet/Leaflet/pull/2607 which might be related. However, all of these have occurred at ~2012-2014 and should well have been mitigated already.

Maybe it's also related to https://github.com/Leaflet/Leaflet/issues/5774 in any way? Similar errors not with the exact same error text can also be found at [3].

[3] https://github.com/Leaflet/Leaflet/search?o=desc&q=Cannot+read+property+%27x%27+of+undefined&type=issues

amotl commented 4 years ago

We should update to the most recent version of Leaflet (see #79) and check if that might resolve this issue.

amotl commented 4 years ago

Dear @DmitrySidorow,

with #81, we will be upgrading to vanilla Leaflet 1.7.1. @robouden has been able to confirm the corresponding pre-release package grafana-map-panel-0.14.0-pre1.zip works for him.

So, I am now humbly asking if you could check this package in your specific environment together with Grafana Track Map [1] and/or Alexandra Track Map [2] to see whether this might resolve the conflict you have been observing?

With kind regards, Andreas.

DmitrySidorow commented 4 years ago

Dear @DmitrySidorow,

with #81, we will be upgrading to vanilla Leaflet 1.7.1. @robouden has been able to confirm the corresponding pre-release package grafana-map-panel-0.14.0-pre1.zip works for him.

So, I am now humbly asking if you could check this package in your specific environment together with Grafana Track Map [1] and/or Alexandra Track Map [2] to see whether this might resolve the conflict you have been observing?

With kind regards, Andreas.

issue still exists :( recorded video: 1) https://www.youtube.com/watch?v=UIRVn7Jtzkc&feature=youtu.be 2) https://www.youtube.com/watch?v=-FzqoSFdneE

how can i help you to resolve that?

DmitrySidorow commented 4 years ago

chrome log.log

maybe log from chrome console will help you

Screenshot_1

amotl commented 4 years ago

Dear Dmitry,

thanks for sharing your investigations.

For whatever reasons, the error might be coming from the intersects method of the Bounds class [1] - specifically from line 1048 [2], which says

xIntersects = (max2.x >= min.x) && (min2.x <= max.x)

So, either min, max, min2 or max2 are undefined here.

This method gets called from the _draw method of the Canvas class [3] - specifically, the culprit is probably line 12341, which says

layer._pxBounds.intersects(bounds)

Without knowing more details yet, the code at one of both places probably should add more sanity checks before operating on the respective Bounds instance.

It looks like https://github.com/Leaflet/Leaflet/issues/5401, https://github.com/Leaflet/Leaflet/issues/6168 and https://github.com/Leaflet/Leaflet/issues/6406 are roughly related to this.

While unrelated to this specific condition, https://github.com/Leaflet/Leaflet/pull/7075 adds more tests for methods of the Bounds class. An eventual pull request should probably do the same, accompanied by improved sanity checks.

With kind regards, Andreas.

[1] https://github.com/Leaflet/Leaflet/blob/v1.7.1/dist/leaflet-src.js#L1038-L1052 [2] https://github.com/Leaflet/Leaflet/blob/v1.7.1/dist/leaflet-src.js#L1048 [3] https://github.com/Leaflet/Leaflet/blob/v1.7.1/dist/leaflet-src.js#L12327-L12349 [4] https://github.com/Leaflet/Leaflet/blob/v1.7.1/dist/leaflet-src.js#L12341

amotl commented 4 years ago

It looks like Leaflet/Leaflet#5401, Leaflet/Leaflet#6168 and Leaflet/Leaflet#6406 are roughly related to this.

@anykeyanykey says at https://github.com/Leaflet/Leaflet/issues/6406#issuecomment-562513731:

[We can observe this issue when using] multiple instances of 'leaflet'.

amotl commented 4 years ago

Dear Dmitry,

I've just also shared your observations at https://github.com/Leaflet/Leaflet/issues/7334.

With kind regards, Andreas.

DmitrySidorow commented 3 years ago

noticed: 1) log in grafana -> grafana-map-panel on start dashboard works good -> go to dashboard with alexandra track map panel -> go to start dashboard: grafana-map-panel breaks 2) log in grafana -> grafana-map-panel on start dashboard works good -> go to dashboard with alexandra track map panel -> refresh page -> go to start dashboard: grafana-map-panel works good and doesn't break anymore (until the next re-log)

amotl commented 3 years ago

Dear Dmitry,

thanks for outlining this repro. So, it looks like it is some initialization issue when using Leaflet on different dashboards without clearing the slate by reloading the page.

Can I humbly ask if it also happens the other way round, when going to alexandra track map panel first? Also, does it also happen when navigating to other dashboards without any kind of map and back?

With kind regards, Andreas.

DmitrySidorow commented 3 years ago

I tried to loading the alexandra track map panel first. But this time nothing broke. From this, we can conclude that the problem is in grafana-map-panel.

amotl commented 3 years ago

We can conclude that the problem is in grafana-map-panel.

Bummer! ;]. You did use grafana-map-panel-0.14.0-pre1.zip, right?

DmitrySidorow commented 3 years ago

We can conclude that the problem is in grafana-map-panel.

Bummer! ;]. You did use grafana-map-panel-0.14.0-pre1.zip, right?

yes, 0.14.0-pre1

amotl commented 3 years ago

All right. Currently, I am out of ideas here. When https://github.com/Leaflet/Leaflet/issues/7334 does not make any progress, I might apply some workarounds to our instance by monkeypatching it.

As I am currently short on time, I humbly ask you for some patience - please ping me again if you don't hear back from me. Thanks for your support!

DmitrySidorow commented 3 years ago

All right. Currently, I am out of ideas here. When Leaflet/Leaflet#7334 does not make any progress, I might apply some workarounds to our instance by monkeypatching it.

As I am currently short on time, I humbly ask you for some patience - please ping me again if you don't hear back from me. Thanks for your support!

Hello, how's it going? The problem still exists :( Everything works fine if you do not manually update the page (F5) with the grafana map panel

amotl commented 3 years ago

Hi Dmitry,

thanks for coming back to this. I am sorry to admit I haven't investigated further. Also, Leaflet seems to be low on developer resources as well. This panel is already using the most recent version 1.7.1. If there will be a new release of Leaflet, I will be happy to integrate it right away.

Nevertheless, I might be able to look into the Monkeypatching when I am back at the code base. Sorry that this causes some pains on your end.

Just to clarify:

Everything works fine if you do not manually update the page (F5) with the grafana map panel.

When watching [1] again, it problem appears when displaying the Map panel on one dashboard, then navigating to another dashboard with Trackmap panel and when navigating back to the Map panel, the circles will not come back, right?

Instead of logging out and logging in again, what would happen if you reload the page by hitting F5?

With kind regards, Andreas.

P.S.: Are you still using [2] or did you move on to [3]?

[1] https://www.youtube.com/watch?v=UIRVn7Jtzkc [2] https://github.com/pR0Ps/grafana-trackmap-panel [3] https://github.com/alexandrainst/alexandra-trackmap-panel

amotl commented 3 years ago

At https://github.com/panodata/grafana-map-panel/issues/80#issuecomment-723505393, I said:

Maybe it's also related to https://github.com/Leaflet/Leaflet/issues/5774 in any way?

That might also well be an option to investigate further, as this issue with Leaflet is apparently still not completely solved.

amotl commented 3 years ago

Dear @DmitrySidorow,

Are you still using [2] or did you move on to [3]?

Knowing about this would be helpful if I can catch a slot to rig up a similar setup on my workstation.

With kind regards, Andreas.

DmitrySidorow commented 3 years ago

Dear @DmitrySidorow,

Are you still using [2] or did you move on to [3]?

Knowing about this would be helpful if I can catch a slot to rig up a similar setup on my workstation.

With kind regards, Andreas.

I use [3] You can put both panels in one dashboard to reproduce bug.

amotl commented 3 years ago

Hi Dmitry,

thanks for letting me know. Now, in order to assist my test rig setup, would you be able to share some parts of your setup by any means? For exporting a subset of the data, InfluxDB Fetcher [1] might come to the rescue (do you actually use InfluxDB?). For Grafana Dashboards, the JSON representation will also be helpful.

@Hualin-AUG just recently shared some bits with me for investigating another issue, see #88. If your setup is more private, you might choose to use a private gist and send the URL through email.

Please note that this is just a humble suggestion how we could work together. If that is not possible, I will completely understand it.

With kind regards, Andreas.

[1] https://github.com/hgomez/influxdb

DmitrySidorow commented 3 years ago

Hi Dmitry,

thanks for letting me know. Now, in order to assist my test rig setup, would you be able to share some parts of your setup by any means? For exporting a subset of the data, InfluxDB Fetcher [1] might come to the rescue (do you actually use InfluxDB?). For Grafana Dashboards, the JSON representation will also be helpful.

@Hualin-AUG just recently shared some bits with me for investigating another issue, see #88. If your setup is more private, you might choose to use a private gist and send the URL through email.

Please note that this is just a humble suggestion how we could work together. If that is not possible, I will completely understand it.

With kind regards, Andreas.

[1] https://github.com/hgomez/influxdb

hi! I use postgres 12 + timescaledb' dashboard json: main.zip

amotl commented 1 year ago

Hi Dmitry,

apologies that we did not find enough spare time to get into the details of this issue. By chance, the error might have been mitigated on more recent versions of Grafana, Panodata Map Panel, or Trackmap Panel.

Did you have any chance to validate it, or are you still facing this issue?

With kind regards, Andreas.