Ticket #3062 (closed task: fixed)

Opened 2 years ago

Last modified 2 years ago

make moveTo more efficient

Reported by: ahocevar Owned by:
Priority: minor Milestone: 2.11 Release
Component: Map Version: 2.10
Keywords: mobile Cc:
State: Review

Description

During dragging, we permanently convert between pixels and map units. This was necessary for working with external mapping apis (e.g. google) before we knew about spherical mercator. But these days, we could do the whole dragging with just pixels and hence save a lot of overhead when dragging. This should also greatly improve the user experience on mobile devices.

Attachments

openlayers-3062.patch Download (11.6 KB) - added by ahocevar 2 years ago.
openlayers-3062.2.patch Download (21.2 KB) - added by ahocevar 2 years ago.
openlayers-3062.4.patch Download (10.8 KB) - added by ahocevar 2 years ago.
no longer give the layerContainerDiv a dimension and size, removed center/extent caching
openlayers-3062.5.patch Download (18.7 KB) - added by ahocevar 2 years ago.
final patch, including fix for #3096
3062.patch Download (19.0 KB) - added by crschmidt 2 years ago.
openlayers-3062.6.patch Download (19.3 KB) - added by ahocevar 2 years ago.
now also including fix for #3102

Change History

Changed 2 years ago by ahocevar

  • owner euzuro deleted

Changed 2 years ago by ahocevar

I am attaching a patch which reduces the number of function calls during moveTo, by taking advantage of cached properties and adding caching for additional properties. Before applying this patch, the list of most called functions looks like  this, and after applying the patch like  that.

All tests still pass, and examples continue to work.

Changed 2 years ago by ahocevar

Forgot to mention that the above profiling was done for a single click on the "pan right" button of the pan panel. I don't expect this patch to be committed. Instead, I'm working on doing panning and dragging entirely in pixel space. I'm still attaching the patch for the record.

Changed 2 years ago by ahocevar

Changed 2 years ago by erilem

  • keywords mobile added

Changed 2 years ago by ahocevar

Changed 2 years ago by ahocevar

  • state set to Review
  • component changed from Layer to Map

openlayers-3062.2.patch Download adds an additional improvement: the layerContainerDiv gets the dimension of the map's (baseLayer's) maxExtent at the current resoltuion. Also, the layerContainerDiv is now repositioned on every move, not just on moveend. This seems more natural, saves us additional steps for container repositioning on moveend, and allows further optimization if we add pixel-based move methods, so e.g. pan does not need to convert pixels to coordinates any more. Finally, the fact that the layerContainerDiv now has a dimension, will allow us to position tiles and layers based on a percentages (see #3061).

Replaced a test for layerContainerDiv repositioning (now obsolete) with one that checks for correct layerContainerDiv positioning in map.html.

 Profiling results (left: current behavior, right: behavior after applying the patch)

All tests pass in Safari5. Thanks for any review.

Changed 2 years ago by ahocevar

  • state changed from Review to Needs More Work

Progress on this ticket can be tracked by observing the  layercontainer sandbox.

Changed 2 years ago by ahocevar

Related tickets:

  • #3061 - percentage based tile positioning

Issues that need to be resolved:

  • #3095 - moveByPx for layers
  • #3096 - move EventPane layer
  • #3097 - dragging broken when not using EPSG:4326
  • #3098 - use moveByPx for animated panning
  • #3099 - inRange / visibility updates
  • #3100 - layerContainerDiv positioning may exceed valid css number range

Changed 2 years ago by ahocevar

Another issue:

  • 3102 - wrapDateLine support

Changed 2 years ago by ahocevar

no longer give the layerContainerDiv a dimension and size, removed center/extent caching

Changed 2 years ago by bartvde

@ahocevar: for me the Google v3 test is failing again now in Safari:

test_allOverlays_pan fail 4 ok 4
ok x panning with Google visible 100, -100
fail y panning with Google visible 100, -100. eq: values differ: got 6978393.961914, but expected 6978393.9619141
ok x panning with Google visible -100, 100
fail y panning with Google visible -100, 100. eq: values differ: got 5999999.9999999, but expected 6000000
ok x panning with Google invisible 100, -100
fail y panning with Google invisible 100, -100. eq: values differ: got 6978393.9619139, but expected 6978393.9619141
ok x panning with Google invisible -100, 100
fail y panning with Google invisible -100, 100. eq: values differ: got 5999999.9999998, but expected 6000000

Changed 2 years ago by ahocevar

  • state changed from Needs More Work to Review

All relevant tests pass. Thanks for any review.

Changed 2 years ago by ahocevar

final patch, including fix for #3096

Changed 2 years ago by crschmidt

Changed 2 years ago by crschmidt

Patch had spurious trunk diff, removed.

Changed 2 years ago by ahocevar

now also including fix for #3102

Changed 2 years ago by crschmidt

After having tested all of this functionality as thoroughly as we can, I see no regressions in behavior before and after this patch. It is also noticably faster for dragging the map with touch on slower devices. As far as I am concerned this patch is ready for commit.

Changed 2 years ago by ahocevar

  • status changed from new to closed
  • resolution set to fixed

(In [11535]) New private movePyPx method to avoid going through all the unnecessary pixel-lonlat conversions. p=elemoine,me (closes #3062)

Note: See TracTickets for help on using tickets.