mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

map.on('draw.update', callback) does not fire consistently

Open Plysepter opened this issue 7 years ago • 13 comments

mapbox-gl-js version: v0.39.1, v0.38.0, v0.37.0 mapbox-gl-draw version: v1.0.0, 0.19.0

Steps to Trigger Behavior

  1. Open Plunkr: https://plnkr.co/edit/Rn5AZKlDrdBBAQmdiRy2?p=preview
  2. Open Dev Tools -> Console
  3. Draw a polygon
  4. Update the polygon by moving a point
  5. Repeat step 4 and keep track of the number of times you have moved a point. After a few changes you should notice that the count variable does not represent the number of changes actually made.

Expected Behavior

The draw.update event callback should fire each time a point is moved to a new position. Which in turn would increment the count variable by one.

Actual Behavior

The draw.update event callback is not being fired consistently.

Plysepter avatar Aug 31 '17 18:08 Plysepter

Opened plunker and received error:

api.mapbox.com/styles/v1/mapbox/streets-v9?access_token=pk.eyJ1Ijoic2t5d2F0Y2hhcHBzIiwiYSI6ImNpa3B4aHp6OTE1OWV0bm02aWQwOTd2OG8ifQ.Ic8z13iLo4r39I01ckGvZA Failed to load resource: the server responded with a status of 401 (Unauthorized)

IAfanasov avatar Oct 03 '17 01:10 IAfanasov

Updated Plunker with new key. Sorry about that

Plysepter avatar Oct 03 '17 02:10 Plysepter

moved different points about 20 times. all fired. may you clarify the scenario? may be screencast?

IAfanasov avatar Oct 03 '17 03:10 IAfanasov

I have provided a screencast to better demonstrate the issue. You can skip to about 19 seconds in for the updating to start.

Here are a list of time codes for missed events: 0:22 - Between console log 3 & 4 0:26 - Between console log 5 & 6 0:28 - Between console log 6 & 7 0:36 - After console log 14

I hope that the screen capture better illustrates the issue. I am not sure how to provide more detail other than to share the screen capture and note that while I am able to easily reproduce the issue, there is no specific pattern observed for when the event doesn't fire.

Please let me know if the screen capture helped or if I can be of any more help in tracking down this bug. I appreciate the help

UpdateNotFiring.mp4.zip

Plysepter avatar Oct 03 '17 13:10 Plysepter

can not reproduce. just have guess that it due to some async operations. may be you move point before processing of previous event finished. I don't know MapBoxDraw internals. So it based only on experience. Also, try to update MapBoxDraw. Last version is 1.0.2

IAfanasov avatar Oct 05 '17 01:10 IAfanasov

I am experiencing this as well, running on version 1.0.2 in Chrome 61.0.3163.100 for MacOS.

The issue seems to be intermittent and difficult to reproduce predictably. When it does happen, no draw.update event is fired after a point is moved. The point, however, doesn't revert to its previous location (which might indicate that the event was never completed), but stays where it was dropped. No errors appear in the logs.

mike-marcacci avatar Nov 14 '17 04:11 mike-marcacci

draw.update is controlled by the modes so its a bit weird. Doing a quick search of UPDATE might help track down why this is happening.

mcwhittemore avatar Nov 14 '17 16:11 mcwhittemore

I can confirm this issue as well. Works fine for me in Chrome but on mobile the draw.update doesn't get fired a single time. For example the plunker from above with an alert instead of a console.log https://run.plnkr.co/JL2A9pK1sxpcsMjQ/ doesn't alert on mobile after draw.update but does alert on a none mobile device.

Update: I think it only occurs when updating points. The event fires on line or polygon updates.

bloigge avatar Dec 13 '17 16:12 bloigge

I am experiencing this issue as well, running version 1.0.4 of mapbox-gl-draw and 0.42.1 in Chrome 63.0.3239.84 on macOS Sierra (16G1036).

I'm able to reproduce it by creating a polygon in the plunkr in the original post, and then moving it around with my mouse. Every so often, the update event does not fire when I move the polygon.

rob5standingby avatar Dec 17 '17 02:12 rob5standingby

I stumbled across this issue when testing the mobile browser side of things (desktop seemed consistent) and ran into the exact same scenario @bloigge described.

I ultimately ended up having to wrap my logic in a 'touchend' event and pass all my draw logic within.

dnseminara avatar Mar 19 '18 04:03 dnseminara

I can reproduce the problem. It seems to happen in direct-select mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad. Harder to reproduce with a mouse.

mapbox-gl-draw 1.0.9
mapbox-gl 0.44.2

franciscolourenco avatar Jun 10 '18 12:06 franciscolourenco

I can reproduce this problem 100% of the time on an Android mobile device, and also in Chrome's mobile simulator. This is with the latest version of mapbox-gl-draw: 1.1.1, and version 0.51.3 of mapbox-gl.

Steps to reproduce:

  1. Draw polygon
  2. Click out of the polygon to leave edit mode
  3. Move the entire polygon
  4. The above step does not fire draw.update event

I have verified the problem on Chrome 66 and 72 on an Android device, and also Chrome 72 in the device simulator.

Important note: moving individual points does fire draw.update. The problem only exists when moving the entire shape.

neodescis avatar Mar 06 '19 16:03 neodescis

I am also facing this issue on a macOS computer with a trackpad (Chrome).

blin4444 avatar Apr 23 '22 02:04 blin4444

I made a fork of the v1.4.1 with fix and prepare command. You can try it:

yarn add https://github.com/gynekolog/mapbox-gl-draw.git#119ebc511726e4a54ea1fd499c7ebd853a76ef22

gynekolog avatar Feb 09 '23 16:02 gynekolog

yarn add https://github.com/gynekolog/mapbox-gl-draw.git#119ebc511726e4a54ea1fd499c7ebd853a76ef22

is this in "main" now? I'm still having this kind of issue...

fabrusso avatar Mar 06 '23 14:03 fabrusso

@stepankuzmin I can reproduce the problem. It seems to happen in direct-select mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad.

mapbox-gl-draw 1.4.1 mapbox-gl 2.10.0

Maximenya avatar Mar 16 '23 16:03 Maximenya

Hi @Maximenya,

We haven't yet released a new version of Mapbox GL Draw that includes this fix. Sorry for the inconvenience.

stepankuzmin avatar Mar 17 '23 12:03 stepankuzmin

When will you release the fixed version? Why wait so long to release a bug fix?

bytebene avatar Apr 13 '23 11:04 bytebene

hello, please tell me why when I install the latest version of your package there is no src folder but only dist. i can't update ''mapbox-gl-draw-freehand-mode'' under your update because of this

dwasinside avatar Jun 01 '23 08:06 dwasinside

I tried locally to apply #1160 but I'm still able to reproduce the problem by following @Maximenya instructions:

@stepankuzmin I can reproduce the problem. It seems to happen in direct-select mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad.

Anyone else also facing this issue even after applying the fix?

jdduarte avatar Jun 15 '23 15:06 jdduarte

I tried locally to apply #1160 but I'm still able to reproduce the problem by following @Maximenya instructions:

@stepankuzmin I can reproduce the problem. It seems to happen in direct-select mode while dragging a vertex and releasing the mouse button without stopping to move the mouse. Seems easier to reproduce using a trackpad.

Anyone else also facing this issue even after applying the fix?

Same problem. Testing on v1.4.2

sasfeat avatar Jul 19 '23 09:07 sasfeat

Wondering if anyone else is still experiencing this and if there's any fix for it? Thanks.

jdduarte avatar Dec 04 '23 08:12 jdduarte

Works better, but still with problems on 1.4.3.

piotrmarkiewicz avatar Feb 07 '24 08:02 piotrmarkiewicz