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

Ensure view function is only called on UI thread #1043

Merged
merged 3 commits into from
Jun 1, 2023

Conversation

TimLariviere
Copy link
Member

For performance reasons, we have decided to let init, update and view run on whatever thread the message was dispatched from. This is because the MVU functions don't access the UI itself, Fabulous deals with it exclusively during reconcilation so we only synchronize back to the UI thread during diffing to avoid the perf hit of jumping threads.

But if we need to access some information related to the UI inside the view function (such as the safe area margins), it requires access to the UI thread, otherwise it could crash.

This PR ensures that the view function is called only on the UI thread to avoid those issues.

@TimLariviere TimLariviere merged commit b3c9894 into main Jun 1, 2023
1 check passed
@TimLariviere TimLariviere deleted the sync-view-fn-ui-thread branch June 1, 2023 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant