Fix IAM Tag Sub crash when getTags returns after loading HTML #1060
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
This PR fixes a crash when displaying IAMs with tag sub in a specific timing scenario.
Details
When loading tags for IAM tag sub we load the tags and the HTML content for the IAM in parallel. There was no issue when the getTags request finished prior to loading the HTML, but if loading HTML finished first the App would crash. This is because the getTags request returns on a background thread and calls setWaitForTags on that bg thread. setWaitForTags then instructs the webView to display with the HTML content, but doing so on a background thread is not allowed since it is a UI element. We need to dispatch to the main thread to avoid crashes.
Motivation
Fixes IAM crash
Testing
Manual testing
I have tested IAMs with tag sub on my iPhone when both timing scenarios occur as well as IAMs without tag sub.
Affected code checklist
Checklist
Overview
Testing
We don't have a good way to test UI bg thread issues without UI tests
Final pass
This change is