Skip to content

Cancel pending style request when loading style JSON #3709

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

louwers
Copy link
Member

@louwers louwers commented Aug 8, 2025

#3240 added a new method to load a style JSON from string. However when a map is loading a style asynchronously, this can lead to a race condition where the style set from JSON is overwritten by the incoming style response.

Includes a regression test.

Closes #3708

Copy link
Collaborator

@TimSylvester TimSylvester left a comment

Choose a reason for hiding this comment

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

That looks good.

Using the destructor to potentially do network stuff makes me nervous, but that's another matter.

@louwers
Copy link
Member Author

louwers commented Aug 8, 2025

@TimSylvester Nice. That destructor deletes the FileSourceRequest, which calls the cancellation callback. I don't think that actually cancels in-flight requests so it's not really doing network stuff per se. It also deletes the mailbox. So if there's a network request coming in, it will just send a message to a dead mailbox.

@louwers louwers enabled auto-merge (squash) August 8, 2025 16:04
@louwers louwers self-assigned this Aug 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[iOS] Race condition when initializing map and immediately setting styleJSON
3 participants