Skip to content

Shared global deferred regl causes issues with multiple ReglFrame instances and mounting/unmounting #31

@kevzettler

Description

@kevzettler

The regl calls are deferred, they are not executed until the ReglFrame component mounts and passes a canvas draw context to the reglInit function and then passes a regl reference set method. This will then trigger all the deferred functions to execute. If ReglFrame is unmounted it will call regl.destroy and then when a new ReglFram is mounted it will reinitalize all the deferred functions with the new regl handle. This reinitialization of the deferred function seems to cause some some failures. This can be observed in the storybook by changing between the different stories. This causes a mount and unmount of the ReglFrame components. Which triggers the set/unset of the deferred regl components.

Further concerns are that the deferred resources are defined in shared global scope. So deferred resources that are not part of the ReglFrame component tree are re-initalized. In the story book this means that when you change between stories all of the resources for all other stories are reinitalized.

An idea for improvement here is ReglFrame should not call the global deferred set function which will execution all know deferred functions. Instead ReglFrame should execute a tree of the deferreds it will render. This will have some edge cases where a resources is defined in a scope out side of the render time tree but still used.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions