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

Call to udContext_Connect blocks UI rendering #3

Closed
kressnick25 opened this issue Aug 6, 2020 · 2 comments · Fixed by #14
Closed

Call to udContext_Connect blocks UI rendering #3

kressnick25 opened this issue Aug 6, 2020 · 2 comments · Fixed by #14
Labels
bug Something isn't working

Comments

@kressnick25
Copy link
Owner

Calling udContext_Connect from a widget blocks rendering while the network request is made.
I tried using an Isolate with compute() to call the function from a different thread but ran into the issue that an ffi.Pointer can't be passed as a parameter to an Isolate.

@kressnick25
Copy link
Owner Author

This might be helpful, it seems you can pass a pointer to an Isolate via a message: dart-lang/language#333 (comment)

@kressnick25 kressnick25 self-assigned this Aug 23, 2020
@kressnick25
Copy link
Owner Author

samsinsane wrote:

https://medium.com/@lelandzach/dart-isolate-2-way-communication-89e75d973f34

it looks like you can send anything over the SendPort/ReceivePort - I'm not sure if it's a copy of the memory or if it's transferring the ownership. Given that a number of our APIs tend to hit disk or the network, you might be better off keeping all of the udSDK interactions in the other isolate. Then just send/receive data as required, so logging in could be:

mainToIsolate.send({ event: Login, server: server, email: email, password: password });

or something similar that would work in Dart. I'm not sure how you don't stall the main isolate while waiting for a response from the udSDK isolate though, but I'm sure there's plenty of examples of how that works using futures - probably using a bool to indicate that the future has completed instead of using the await keyword, would be my guess.

I don't think the bool would be required at all - when the main isolate receives a message from the udSDK isolate, it would just change the state of the application at that point to logged in with whatever additional information you send back to the main isolate.

@kressnick25 kressnick25 removed their assignment Aug 23, 2020
@kressnick25 kressnick25 added the bug Something isn't working label Oct 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant