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

Layer stays in "Awaiting State" #2131

Closed
3 tasks
SymbolixAU opened this issue Jul 28, 2018 · 4 comments
Closed
3 tasks

Layer stays in "Awaiting State" #2131

SymbolixAU opened this issue Jul 28, 2018 · 4 comments

Comments

@SymbolixAU
Copy link
Contributor

SymbolixAU commented Jul 28, 2018

Issue

I'm building a non-react application using R and Shiny (Shiny is a package for building web apps from r)

I can render layers without issue, but I can't get them to update.

Actual Result

This screenshot shows a scatterplot layer and an arc layer. Both layers rendered at startup. I've logged the arcLayer in the console. The first object in the console shows the lifecycle value

lifecycle: "Initialized"

screen shot 2018-07-28 at 4 39 55 pm

I then changed the country to Zimbabwe (it started at the UK, where the arcs originate), and pressed the update map button.

This logged the updated arcLayer in the console as

lifecycle: "Awaiting State"

The data prop in the arcLayer is successfully changing, but the layer stays at "Awaiting State"

How can I make the layer update? Is there a way to force the layer to update?

Let me know if you need any extra details.

To Do List

  • Add label and assign to milestone
  • Coding
  • Test
@ibgreen
Copy link
Collaborator

ibgreen commented Jul 28, 2018

@SymbolixAU "Awaiting state" means the layer has just been created, but not processed/matched by deck.gl. The second set of layers need to be supplied to deck.gl so that they can be matched against the previous "generation" layers (or initialized, if new). If you are using Javascript API you need to call something like:

deckgl.setProps({layers: [newArcLayer, newScatterplotLayer]});

Also try setting deck.log.priority = 4 (try different values 1-4) in the console and see if you get any tracing of the lifecycle.

@SymbolixAU
Copy link
Contributor Author

@ibgreen

A bit further digging. If I just use one layer, every time I call

deckgl.setProps({ layers:  arcLayer  })

The update works as expected.

However, I have to keep track of the layers in an array (because the user can update individual layers at a time), so doing

myLayerArray = [];
myLayerArray.push(arcLayer);
myLayerArray.push(scatterLayer);
deckgl.setProps({ layers: myLayerArray });

works at start-up.

But if I replace myLayerArray.arcLayer with a new ArcLayer, but keeping the id the same, when setting it to deckgl.props I see the "Awaiting state" issue as per my original screenshots.

In the absence of a fully reproducible example, when the user presses the 'update button ' the workflow is

const arcLayer = new deckgl.ArcLayer({ id: 'arc_id', ... });
// replace myLayerArray.arcLayer with this new arcLayer

deckgl.setProps({ layers: myLayerArray });

@SymbolixAU SymbolixAU mentioned this issue Jul 28, 2018
2 tasks
@ibgreen
Copy link
Collaborator

ibgreen commented Jul 30, 2018

// replace myLayerArray.arcLayer with this new arcLayer

True to its Reactive roots, deck.gl does shallow comparison on almost everything. If you send it the same array, it will not do a deep comparison and and just not update. Try creating a new array, e.g:

deckgl.setProps({ layers: [...myLayerArray] });

@SymbolixAU
Copy link
Contributor Author

@ibgreen Yes! that's the one. Thanks.

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

No branches or pull requests

1 participant