Code Monkey home page Code Monkey logo

Comments (7)

grigasp avatar grigasp commented on July 4, 2024

I looked at what changed between dev.25 and dev.37 and think that this is the cause - iTwin/imodel-native#550. Most likely we're now able to find the cached provider with old data and don't attempt to re-load it. I'll try to reproduce this locally to confirm.

In the meantime, can you try to set the { caching: { content: { size: 0 } } } when initializing Presentation on the backend and see if that helps?

from viewer-components-react.

grigasp avatar grigasp commented on July 4, 2024

While it looks like iTwin/imodel-native#550 is what caused this to stop working, I don't think there's anything wrong with the change as it just makes sure we actually use our cache rather than re-create content on each request.

I confirmed we are correctly tracking element changes in the iModel and clearing affected cache entries as necessary. Added a test to prove that it works: iTwin/itwinjs-core@master...presentation/content-after-imodel-changes. @Rock2000, can you have a look at the test and your set up and see if there're any differences?

A few notes:

  • updatesPollInterval is required when calling Presentation.initialize on the backend for changes to be tracked.
  • You'll notice some hacks in my test related to IPC and Txns - those should not be necessary in a real set up.

from viewer-components-react.

Rock2000 avatar Rock2000 commented on July 4, 2024

The { caching: { content: { size: 0 } } } options seems to 'fix' it, if that helps any. Let me try to look at the test

from viewer-components-react.

Rock2000 avatar Rock2000 commented on July 4, 2024

Setting updatesPollInterval:1 also seemed to fix it. Is that the correct fix? Does it make sense that things seemed to work previously without this flag? Also I'm not sure how to pick a good value. What is occurring during this interval? Is it polling the backend from the frontend?

from viewer-components-react.

grigasp avatar grigasp commented on July 4, 2024

Setting updatesPollInterval:1 also seemed to fix it. Is that the correct fix?

Yes, setting updatesPollInterval is the correct fix. I figure neither name nor the docs of this attribute are perfect - I filed an issue for improving that.

Does it make sense that things seemed to work previously without this flag?

Setting the attribute does two things (both on the backend):

  1. Registers iModel data changes listener that clears affected entries from various caches and creates "update records" describing what changed.
  2. In our TS backend part, polls the "update records" from addon at the specified interval and streams them to the frontend for components to know what to update.

In dev.25 there was a bug that caused us to always miss cached content entries, so you always got fresh content even without clearing the cache entries. With that bug fixed, performing the step 1 above became important.

Without this attribute, even in dev.25, I would assume the property grid didn't auto-reload when you changed a value, did it?

Also I'm not sure how to pick a good value. What is occurring during this interval? Is it polling the backend from the frontend?

See above for what it's polling. Polling happens on the main backend's thread, so I would avoid setting this to something smaller than 5 ms. On the other hand, setting a large poll interval will make components "lag" to update, so it probably shouldn't be larger than 20 ms or similar.

from viewer-components-react.

Rock2000 avatar Rock2000 commented on July 4, 2024

Yeah the property grid did refresh automatically in 25 and even earlier. We've had the property grid added for a couple months, and although we don't use it much yet it has seemed to work up until 37.
But I'll add the polling value as that does fix it. Thanks

from viewer-components-react.

grigasp avatar grigasp commented on July 4, 2024

Closing this issue as it's now resolved and further improvements will be tracked by iTwin/itwinjs-core#6338.

from viewer-components-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.