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

Fix IAM Tag Sub crash when getTags returns after loading HTML #1060

Merged
merged 1 commit into from
Mar 22, 2022

Conversation

emawby
Copy link
Contributor

@emawby emawby commented Mar 21, 2022

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

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
    We don't have a good way to test UI bg thread issues without UI tests
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

This change is Reviewable

The getTags request returns on a background thread and class setWaitForTags on that bg thread. We need to dispatch to the main thread to avoid crashes.
@emawby emawby requested review from jkasten2, nan-li and a team March 21, 2022 16:43
Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @nan-li)

Copy link
Member

@jkasten2 jkasten2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @nan-li)

@emawby emawby merged commit cb58ec5 into main Mar 22, 2022
@emawby emawby deleted the fix/crashing_iams_with_tag_sub branch March 22, 2022 20:50
@emawby emawby mentioned this pull request Mar 22, 2022
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.

2 participants