Comments (6)
I feel like we may be talking about different things here. Maybe we need another whiteboard session or something :)
from wgpu-py.
Well, I agree, but I also think it's important that we make this library easy to integrate. I don't want Qt users to deal with async-ness when they are completely unfamiliar, they will just get frustrated. Perhaps we can provide a sync version of the API or event loop adapter layers... I'm not sure. Let's keep the brainstorm going on this one...
from wgpu-py.
Short answer: wgpu has a few async functions by design, but we should not pin down on asyncio
, but allow people to use trio
or any other async lib.
The only use of asyncio
is in requestAdapterSync()
to provide a sync version of requestAdapter
. I think we should indeed remove that. Our examples are now set up to be async, so we don't need it anymore.
However, the wgpu has a few functions that are async by design, i.e. these are async def
, and we'll have to deal with that. I think we need some async library (asyncio or trio or ...) for that in the example, I don't think the native GUI event loops suffice, right?
from wgpu-py.
I was thinking about this a little bit more this morning, and in particular, this triggered me:
The only use of asyncio is in requestAdapterSync() to provide a sync version of requestAdapter. I think we should indeed remove that. Our examples are now set up to be async, so we don't need it anymore.
I think this might actually be very good to keep around. When I work with C#, it's quite normal for libraries to expose both async and sync APIs for the same functionality. This is often very convenient, since you might want to use a library call outside an event-loop managed area such as database migration or CLI scripts.
I think we should acknowledge that our target deployment is mainly going to be desktop GUI frameworks and rendering scripts, where async io has definitely not become mainstream yet.
So, I have two questions:
- Can we provide a sync version of all async methods using
run_until_complete
? - Can we make it optional to setup an event-loop? It seems to me the sync API could very easily just use an internal isolated event loop instance that only runs for the duration of that call?
I think that would bring us where we want to be. IDL compliance, no event-loop boilerplate for users and we still offer all the advanced options for power users.
from wgpu-py.
Can we provide a sync version of all async methods using
run_until_complete
?
I should think so ... But we may better wait for a bit, since wgpu-native
is evolving towards having an actual event-loop, and I'm not sure yet whether it's enough to only "integrate" with it during an async call, or whether we must somehow keep it alive all the time.
Can we make it optional to setup an event-loop? It seems to me the sync API could very easily just use an internal isolated event loop instance that only runs for the duration of that call?
If we can answer the previous question with yes, I see no reason why the user would have to deal with an event-loop.
I think it makes sense that a user should choose to either use the async API or the sync API, not a mix.
from wgpu-py.
In #43 every async method also gained a sync (blocking) version. I think we can manage to keep this up one way or another.
from wgpu-py.
Related Issues (20)
- Error when no draw function is provided HOT 1
- Warnings on import HOT 1
- test_glfw_canvas_del Windows fatal exception: access violation HOT 6
- Full-screen mode HOT 7
- Rolling out shadertoy HOT 5
- Run examples on CI on Windows / Mac / Linux
- Use webgpu.yml for parsing HOT 2
- Kivy support HOT 1
- HDR Support HOT 1
- Blocking render call HOT 2
- The expression may only be indexed by a constant HOT 3
- Update testing mechanics
- GPU info and identification HOT 21
- WxWgpuWindow object has no attribute 'add_event_handler' HOT 7
- Idea: auto-generated bindings for webgpu-native HOT 3
- Retry release for v0.15.1 ? HOT 1
- Change emum/flag implementation
- Minimal backend canvas API
- Document requirements to run in cloud/remote environments HOT 7
- Windows fatal exception: stack overflow during passing tests HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wgpu-py.