openlayers / openlayers/openlayers

Updating WebGL layer rendering during animation/interaction with the view

Open
#17,035 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
12.6k
Forks
3.2k
Avg merge
2d 17h
Merged PRs (30d)
21

Description

I have a WebGLVectorLayer object to which I apply this style:

layer.setStyle({
     'icon-src': './sprite.png',
     'icon-offset': ['get', 'offset'],
     'icon-size': [52, 52],
     'icon-scale': ['get', 'scale'],
     'z-index': 1
});

I have several methods inside my application that changes the icon-offset every 200ms to animate the sprite by changing the frame. I decided to use this method and not expressions to keep the full control and allow deeper interaction with the rest of my code.

But it seems that when I'm interacting with the map, or when a view animation is running, the updating of the frames stops (more info on my code in this issue).
I'm using requestAnimationFrame(); to handle the frame update.

I've tried using:

function animate() {
  map.render();
  window.requestAnimationFrame(animate);
}
animate();

and use layer.changed() whenever the frame is updated as suggested by jahow in this issue with no luck.

Am I missing something or this issue could be caused by something elsewhere in my code? I do have some "postrender" events here and there that changes other layers.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the WebGLVectorLayer style using icon-offset and the requestAnimationFrame loop described here, then compare map.render() and layer.changed() while a view animation or map interaction is active. Review the related issues 17033 and 11250, including the postrender handlers, and build a minimal reproduction. Done means identifying whether OpenLayers stops the redraw or whether application code causes the frame updates to stop.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.