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

Maps are slow / lag on iOS Safari (mobile) #1529

Closed
merganon opened this issue Jul 12, 2021 · 6 comments
Closed

Maps are slow / lag on iOS Safari (mobile) #1529

merganon opened this issue Jul 12, 2021 · 6 comments
Labels

Comments

@merganon
Copy link

merganon commented Jul 12, 2021

Description

Heys guys, thanks for your work!

I have noticed that the maps tend to be very slow and laggy on iPhones. Swiping and zooming around is raggedly.

Repro Steps

Choose any map on the examples page on an iPhone: https://visgl.github.io/react-map-gl/examples
Especially: https://visgl.github.io/react-map-gl/examples/clusters

On computer the maps are running fine and smooth, however on iPhones (which use WebKit as render engine for their browsers) swiping and zooming is very laggy.

Environment (please complete the following information):

  • Library Version: ^6.1.16
  • React Version: ^17.0.2
  • Browser Version: Safari 14.1
  • OS: iOS 14.6
@merganon merganon added the bug label Jul 12, 2021
@Pessimistress
Copy link
Collaborator

Which model of iPhone are you using? I have a SE 2020 and do not notice any lagging with the website.

@merganon
Copy link
Author

I'm on an iPhone 6s with latest version of iOS (14.6)

@KoenLav
Copy link

KoenLav commented Aug 4, 2021

We are experiencing the same issue (even after memoizing our layers/features): mid-range Android phones (200 EUR) working perfectly fine, high-range iPhone (1400 EUR) working very glitchy.

We were using react-mapbox-gl first, where we noticed the issue, then switched to this package but the issue persists. So it is possible the issue is with MapBox GL JS in general.

We have narrowed down the problem to (much) more frequent calls to onViewportChange on iOS when compared to Android/Windows (probably touch events firing more frequently in iOS).

What we did for now was debounce the onViewportChange method with 2ms, which seems to have alleviated the issue (although obviously this also makes the interface a little more glitchy for every device, rather than only the devices with the issue).

@KoenLav
Copy link

KoenLav commented Aug 6, 2021

A suggestion: we would like to use asynRender AND not use state to control the viewport, whilst still being able to pan/zoom the map.

This way we can enjoy 100% of the 'native' Mapbox GL JS performance whilst still being able to use onViewportChange or onViewStateChange to figure out when we want to 'refresh' the GeoJSON layers.

We're not making use of Markers or Popups, so these getting out of sync doesn't matter to us.

@Pessimistress would this be possible? (Happy to work on a PR, preferably with some pointers to start.)

ps if we would need to programmatically change the viewport of the map we would access the 'native' instance.

@Pessimistress
Copy link
Collaborator

If you set asyncRender={true} on the map component it should give you the same rendering behavior as native mapbox-gl.

@Pessimistress
Copy link
Collaborator

This is being addressed in v7.0. Please follow #1646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants