Skip to content

Fix threading problem when SDK inits#6

Closed
lukkas wants to merge 1 commit intomasterfrom
fix/callback-queue-crash
Closed

Fix threading problem when SDK inits#6
lukkas wants to merge 1 commit intomasterfrom
fix/callback-queue-crash

Conversation

@lukkas
Copy link
Copy Markdown
Collaborator

@lukkas lukkas commented Mar 20, 2026

It should fix the crash: https://findhotel.sentry.io/issues/7245666115/?project=4508398661074946
We dispatch the callback from SDK initialization back to the main thread.

Looks that the Swift SDK can call us back on an arbitrary queue, while it should be the main queue the communicate via Flutter channels as far as I am aware.

Also, there's some state modification in that callback block, which doesn't look like it's thread safe.

When investigating the Swift SDK I could confirm, that the work is dispatcher on the background thread and never disptached back to main when calling bak the original start caller:
https://github.com/optimizely/swift-sdk/blob/fdefe531d3c4c44eff7f77f7d32dd20fbfd984e5/Sources/Optimizely/OptimizelyClient.swift#L146
https://github.com/optimizely/swift-sdk/blob/fdefe531d3c4c44eff7f77f7d32dd20fbfd984e5/Sources/Customization/DefaultDatafileHandler.swift#L67

@damian-kaczmarek
Copy link
Copy Markdown
Collaborator

I pinged the author on original package PR with fix optimizely#98

@lukkas
Copy link
Copy Markdown
Collaborator Author

lukkas commented Mar 25, 2026

I pinged the author on original package PR with fix optimizely#98

Perfect 👌

I'll close this and integrate the changes tomorrow.

@lukkas
Copy link
Copy Markdown
Collaborator Author

lukkas commented Mar 26, 2026

git replaced with: #7

@lukkas lukkas closed this Mar 26, 2026
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