-
Notifications
You must be signed in to change notification settings - Fork 228
Make element cloning async #8615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@khanaffan @ColinKerr @aruniverse problem: |
We’re considering two strategies to enable asynchronous handling:
I believe the second approach is feasible for these handlers, as it requires minimal code changes. However, this work will need to be scheduled. |
|
…e' into pmc/clone-text-style
@DanRod1999 anyone else in imodel-transformer orbit who should review this PR? |
FYI @mindaugasdirg |
@khanaffan more concurrent query test flakery.
|
I have seen this failing today. I looking at it. |
@dassaf4 @saeeedtorabi Voronoi test flaked out.
|
@pmconne This test generates 100 random points and had never failed until now. Since it's random, we cannot regenerate it. However, we added logs here #8639, so next time it failed we can regenerate it. Please note that I ran it 10 more times locally (i.e., for 10000 random points) and it never failed. |
This began as part of #8534.
Cloning a text style requires importing a font, which is an async operation. Cloning a text annotation element requires cloning a text style. I expect some other element types may need to perform asynchronous operations during cloning as well.
Element.onCloned
was previously synchronous, returningvoid
. Now it returnsvoid | Promise<void>
. This permits existing subclasses that declare their return types asvoid
to continue compiling, but they will receive a lint error (assuming they've configuredno-floating-promises
) if they callsuper.onCloned
withoutawait
.onCloned
isprotected
, so only subclasses ofElement
can invoke it legally.IModelElementCloneContext.cloneElement
calls it illegally viajsClass["onCloned"]
. So doesIModelTransformer
from the imodel-transformer package, which overrides (and does not call - but almost entirely copy-pastes the contents of -super.cloneElement
).IModelElementCloneContext.cloneElement
is@internal
. It used to returnElementProps
. Now it returnsPromise<ElementProps>
.The only implementations of
onCloned
that actually return aPromise
are all currently leaves in the BIS class hierarchy:TextAnnotation2/3d
andAnnotationTextStyle
. So existing code that currently callssuper.onCloned
withoutawait
will continue to function the same. However, existing code that callsIModelElementCloneContext.cloneElement
withoutawait
ing will no longer compile. Since that's an@internal
API, theoretically nobody should be calling it therefore nobody should be affected.We need to talk to the transformer people about how their package and its consumers (including "evergreen" products like drawing production) are supposed to work with the transformer's dependencies on
@internal
APIs.