-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Make !Send data initalization use closures #24390
Copy link
Copy link
Open
Labels
A-AppBevy apps and pluginsBevy apps and pluginsA-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsA-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-Tracking-IssueAn issue that collects information about a broad development initiativeAn issue that collects information about a broad development initiativeD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examples
Milestone
Description
Metadata
Metadata
Assignees
Labels
A-AppBevy apps and pluginsBevy apps and pluginsA-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsA-WindowingPlatform-agnostic interface layer to run your app inPlatform-agnostic interface layer to run your app inC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-Tracking-IssueAn issue that collects information about a broad development initiativeAn issue that collects information about a broad development initiativeD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examples
Type
Projects
StatusShow more project fields
Needs SME Triage
This is a tracking issue for making
!Senddata use closures for initialization.Goal
We currently allow users to directly insert instances of non-send types into a bevy
Appbefore startup. This pins that app, and the entire ECS update loop, onto the thread on which those types are constructed (usually the main process thread), and forces us to mount the ECS update loop within the windowing update loop.This "run-loop turducken" is cursed and bad, and no one I have ever talked to thinks this is a good idea. The first step to removing it is fixing the initialization step. Soooooo...
Proposal
Sendclosures that insert objects into the "Main-Thread Storage" during setup.Closures provided to this function will be retained in the app, and then called only once the runner has started up it's ecs event-loop (on a thread of it's choosing).
Deprecate all existing ways to directly insert
!Senddata.We do not have to deprecate
init_non_send(orinit_main_thread_storageor whatever it's called at this point). We do have to deprecateinsert_non_send; users should try to migrate tosetup_non_sendinstead.After a full release, remove the deprecated methods.
As follow up, move the ECS out of the main windowing thread, then initialize the non-send data on that new thread.
Tracking
This has the potential to break users, so we are going to "scream-test" it. This issue should be the main place to discuss the change, and any issues caused by it.