question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistency with setItemIndex and Navigator / World state

See original GitHub issue

When calling setItemIndex inside a add-item callback, there is an inconsistency in the World and Navigator states. The former has the item that triggered the add-item callback, but World does not.

So, given this use case:

  • add an item with viewer.addTiledImage
  • code in add-item callback inspects world._items and determines that one of the items needs to be moved to top of the list, so it calls setItemIndex
  • setItemIndex updates World state, and dispatches the item-index-change event
  • item-index-change fires.

However, since the Navigator state does not yet have the item from add-item, an error is thrown:

Uncaught Error: Index bigger than number of layers.

I’m not sure if this matters in our use case, since the Navigator state eventually does include the item, it is just in a different ordering than World. However, I think the expected behavior would be that state for both would be updated when the add-item callback fires.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
iangilmancommented, Jun 30, 2020

Good catch! I guess to fix it we would have to make sure the navigator gets the add item event before anyone else.

Meanwhile a workaround could be putting a setTimeout of 1 in your add-item handler, to give the chance for the navigator to catch up.

Thank you for reporting this! If you’re interested in working on a fix, I’m happy to answer any questions you have along the way. Otherwise hopefully someone will take an interest in it.

0reactions
iangilmancommented, Jul 8, 2021

Fixed by #2005

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hyperledger Fabric world state inconsistency - Stack Overflow
I created a paper with the paperlist abstraction and then changed one of its attributes. When getting the state (getState) for a particular ......
Read more >
Unreal Engine 5.1 Release Notes
The navigation data is now externally packaged, which means building a world-partitioned Navmesh does not dirty the main map anymore. In addition, when...
Read more >
Alexa.Presentation.APL Interface Reference | Alexa Skills Kit
The Alexa.Presentation.APL interface provides directives and requests that display content on a device with a screen, such as an Echo Show.
Read more >
browser-extension/changelog.txt at master - openseadragon
Fixed: setItemIndex method not working with navigator inside "open" event ... Fixed problems with zoom/pan constraints with certain extreme settings (#965).
Read more >
Application Cache is a Douchebag - A List Apart
... to keep growing and growing until it hits some kind of browser cache limit and the world explodes. ... setItem( 'index', JSON.stringify(...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found