Giter VIP home page Giter VIP logo

Comments (5)

emilk avatar emilk commented on May 28, 2024 1

Thanks for describing the fix! I'll re-open this as a reminder to add docs, or add WorkerGlobalScope to eframe

from egui.

emilk avatar emilk commented on May 28, 2024

Interesting!

The fix could be for NeedRepaint::repaint_after to try to get the current time and on failure set repaint_time to -INF to just force a repaint asap. ctx.request_repaint_after(…) would not work properly from a web-worker though. Not sure how to handle that case.

from egui.

zdimension avatar zdimension commented on May 28, 2024

It's possible to get the time though, chrono::Local::now() works from the web worker. But eframe is using the Performance api which isn't exposed by js-sys for workers apparently (though the object is useable from workers). Either we could write some kind of wrapper for that that calls the Performance api without using the window object, or when called from a web worker request_repaint could use the low resolution time.

from egui.

white-axe avatar white-axe commented on May 28, 2024

web-sys exposes the Performance API for workers as web_sys::WorkerGlobalScope::performance. You just need to be using web-sys 0.3.65 or later and have the Performance and WorkerGlobalScope features enabled.

from egui.

zdimension avatar zdimension commented on May 28, 2024

web-sys exposes the Performance API for workers as web_sys::WorkerGlobalScope::performance. You just need to be using web-sys 0.3.65 or later and have the Performance and WorkerGlobalScope features enabled.

Thanks, that was it! Performance was already listed by eframe but not WorkerGlobalScope, adding it fixed the problem. I think mentioning that in the docs somewhere (for other people who'd like to use egui along with Web Workers) could be good

from egui.

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.