Skip to content

Figure out when callbacks are called, and on what thread #18

@austinEng

Description

@austinEng

Currently in Dawn, we have to call device.Tick() repetitively in order to make progress and receive callbacks. If there are any pending callbacks, they're resolved on the same thread that you call Tick(). We've been thinking about removing Tick and checking callback completion on a separate thread. This has opened up a couple of possible ways forward, and we should have the behavior consistent for users of webgpu.h

1. Use Tick

  • Calling this in a loop is particularly wasteful.
  • It's easy to misuse -- calling it often all the time or not at all
  • It isn't part of the JavaScript API.
  • It does however let the application most explicitly control when callbacks are delivered
  • May require an application to do their own cross-thread posting if they want to process the callback somewhere else

2. Call callbacks on a separate thread

  • May require an application to do their own cross-thread posting if they want to process the callback somewhere else
  • The application receives the callback on a thread it didn't create -- exposing an implementation detail

3. Forward callbacks to the originating thread

  • May require an application to do their own cross-thread posting if they want to process the callback somewhere else
  • Requires the implementation to check at every / most API calls if there's a callback to process
  • This is probably where an application wants to receive a callback, so it's nice if we do it for them.

I lean toward option (2). Having (1) is a fairly inefficient solution. I don't want to have the implementation do extra work to implement (3), especially if an application already manages cross-thread tasks itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    asyncAsynchronous operations and callbacks

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions