Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Plysepter opened this issue Aug 31, 2017 · 23 comments · Fixed by #1160
Closed

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

Plysepter opened this issue Aug 31, 2017 · 23 comments · Fixed by #1160
Labels
bug touch-specific ui Buttons & user interactions

Comments

@Plysepter
Copy link

Plysepter commented Aug 31, 2017

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.

@IAfanasov
Copy link

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)

@Plysepter
Copy link
Author

Updated Plunker with new key. Sorry about that

@IAfanasov
Copy link

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

@Plysepter
Copy link
Author

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

@IAfanasov
Copy link

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

@mike-marcacci
Copy link
Contributor

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.

@mcwhittemore
Copy link
Contributor

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.

@bloigge
Copy link

bloigge commented Dec 13, 2017

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.

@rob5standingby
Copy link

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.

@dnseminara
Copy link

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.

@franciscolourenco
Copy link
Contributor

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

@neodescis
Copy link
Contributor

neodescis commented Mar 6, 2019

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.

@blin4444
Copy link

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

@gynekolog
Copy link
Contributor

gynekolog commented Feb 9, 2023

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

@fabrusso
Copy link

fabrusso commented Mar 6, 2023

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

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

@Maximenya
Copy link

@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

@stepankuzmin
Copy link
Contributor

Hi @Maximenya,

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

@bytebene
Copy link

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

@dwasinside
Copy link

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

@jdduarte
Copy link

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?

@sasfeat
Copy link

sasfeat commented Jul 19, 2023

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

@jdduarte
Copy link

jdduarte commented Dec 4, 2023

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

@piotrmarkiewicz
Copy link

Works better, but still with problems on 1.4.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug touch-specific ui Buttons & user interactions
Projects
None yet