Skip to content

Conversation

danbenner-vega
Copy link
Contributor

@danbenner-vega danbenner-vega commented Sep 16, 2025

  • For some reason the tileOverlays was set as an array. It's never used as an array. The parent never sees more than one in the array. I made it a single object. Seems to have solved the problem.
  • Second, I've wrapped problematic calls to refresh() function to stay on main thread now.

jmckomni
jmckomni previously approved these changes Sep 29, 2025
Copy link
Contributor

@brentvegafederal brentvegafederal left a comment

Choose a reason for hiding this comment

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

One small note to think about, but code looks good.

Copy link
Contributor

@paulsolt-ofsw paulsolt-ofsw left a comment

Choose a reason for hiding this comment

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

This solution is not the right solution.

We have a concurrency bug that I documented with multiple threads accessing the same shared data in the createTileOverlays() method. Changing the type of the published property might punt the crash and doesn't solve anything about concurrent access. It might appear to be less likely to crash, but it is still just as unsafe.

Both Task 10 and Task 11 are modifying the same shared resource from concurrent queues. This is unsafe code to be modified by both Tasks concurrently.

We need to protect with either actor, serial queue, or static @mainactor protections to prevent modifying shared state from two different threads at the same time.

2025-9-29 Concurrency bug

Copy link
Contributor

@paulsolt-ofsw paulsolt-ofsw left a comment

Choose a reason for hiding this comment

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

Looks better. I'm not sure what approach actually solves the concurrency issue.

It almost feels like it's because the Task might be on a background thread inside the .sink. So that we'd need await MainActor.run { to do the main thread work on the proper thread.

Copy link
Contributor

@paulsolt-ofsw paulsolt-ofsw left a comment

Choose a reason for hiding this comment

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

Looks good. I have not seen a crash on the simulator or iPhone 15 Pro Max running on this branch.

The new changes should make this logic safer. In the future we can explore more @mainactor changes, or make it the default in Swift 6.2 with Xcode 26.

@paulsolt-ofsw paulsolt-ofsw merged commit 11160dc into develop Oct 7, 2025
@paulsolt-ofsw paulsolt-ofsw deleted the dbenner/create-tile-arrays-unsafe branch October 7, 2025 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants