Skip to content
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

Handle async design function #143

Open
runemadsen opened this issue Sep 2, 2022 · 5 comments
Open

Handle async design function #143

runemadsen opened this issue Sep 2, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@runemadsen
Copy link
Contributor

Is your feature request related to something something in Mechanic? Please describe.
We should support async design functions

Is your feature request related to a problem? Please describe.
It actually works, but the canvas seems to be rendered multiple times when updating the values
Screen Shot 2022-09-02 at 2 31 31 PM

Describe the solution you'd like
That I can write a design function that uses async and it just works. This would not be something that could be used for engine-react since React components are not allowed to be async.

@runemadsen runemadsen added the enhancement New feature or request label Sep 2, 2022
@fdoflorenzano
Copy link
Contributor

From what I see, this specifically happens (from what I gather in the photo) because of a combination of things. That design function has to read the image being loaded, which in a way timeouts the call for done, and if we change values in the UI very quickly, like moving the slider very fast (without debouncing), then multiple calls for done with different canvas lineup together with the most recent call for the engine, and the canvas engine doesn't know how to handle that.

A simple tweak would be clearing the content in the root element of the iframe for each frame/done call.

Also, unrelated, did you load a picture of your ID? lol

@runemadsen
Copy link
Contributor Author

Ah, I see. That actually makes sense in this case too, so that's probably what happened. And yes, I only had a picture of my passport and realized right when I was about to post this issue that it might not be a good idea to upload the screenshots unaltered 😂

@lucasdinonolte
Copy link
Contributor

Seeing this – might not be 100% related to the async question – made me think about the image input: Would it make sense to move the async image loading to that input? So a design function is always passed a base64 image it can use immediately?

I think this would make design functions a bit cleaner as it would remove user code to turn the FileBlob into an image they can work with.

@lucasdinonolte
Copy link
Contributor

I just tried the above approach and this would actually lead to exceeding the local storage quota really fast 📦🥸

@fdoflorenzano
Copy link
Contributor

Yeah that's the original reason we didn't do it that way. It somehow needs to involve uploading the image somewhere and keeping a reference to it. We've discussed a couple of times in the past about maybe adding a config prop that gives the auth credentials for an S3 bucket or Dropbox folder to make this happen as an option for better image handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants