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

Run runActivity on main thread (#895) #896

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sk409
Copy link

@sk409 sk409 commented Aug 27, 2024

Fixes #895 .

@mbrandonw
Copy link
Member

Hi @sk409, I believe the only way runActivity could be called on a background thread is if your test is running on a background thread. Instead of this change can you mark your test with @MainActor?

We have plans to more deeply integrate snapshot testing with Swift's concurrency tools, but until then you will need to be responsible for calling its APIs on the main thread.

@sk409
Copy link
Author

sk409 commented Aug 30, 2024

@mbrandonw
My app uses SDWebImageSwiftUI to display images.
SDWebImageSwiftUI updates views on the main thread, so when I run the test on the main thread, XCTWaiter.wait blocks updating views. Therefore, the image will no longer be displayed in the snapshot.
For the reasons mentioned above I need to run my tests on a background thread instead of the main thread.

※SDWebImageSwiftUI performs the following processing on the main thread.

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