[FSSDK-12503] fix: guard static MethodChannel from multi-engine overwrite#103
Open
muzahidul-opti wants to merge 5 commits intomasterfrom
Open
[FSSDK-12503] fix: guard static MethodChannel from multi-engine overwrite#103muzahidul-opti wants to merge 5 commits intomasterfrom
muzahidul-opti wants to merge 5 commits intomasterfrom
Conversation
When FirebaseMessaging.onBackgroundMessage (or any mechanism that creates a second FlutterEngine) triggers onAttachedToEngine a second time, the static channel was unconditionally overwritten. This caused notification callbacks to route to the wrong engine, silently dropping them. The fix adds an early return if channel is already set, and nulls the channel in onDetachedFromEngine so re-attachment works after a real detach. Fixes FSSDK-12503 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Same root cause as the main channel fix — the static logger channel could be overwritten by a second FlutterEngine. The setChannel guard allows explicit null (cleanup) but prevents overwrite of an active channel. Fixes FSSDK-12503 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Same vulnerability as Android — if register(with:) were called twice (e.g. by a second FlutterEngine), the static channel would be overwritten. The fix adds an early return if channel is already set. Fixes FSSDK-12503 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Same pattern as the Android logger fix — prevents a second engine from overwriting the active logger channel. Fixes FSSDK-12503 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…annels Replace the compound null-guard logic with explicit setChannel (only sets if no active channel) and clearChannel (always clears). This matches the main plugin's pattern and makes intent immediately obvious. Callers updated: onDetachedFromEngine now calls clearChannel() instead of setChannel(null). Fixes FSSDK-12503 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
onAttachedToEngine(Android) /register(with:)(iOS) is called more than onceMethodChannelwas unconditionally overwritten by a second Flutter engine (e.g. Firebase background messaging), causing notification callbacks to route to the wrong engineonDetachedFromEnginefor proper lifecycleChanges
OptimizelyFlutterSdkPlugin.java: Early return inonAttachedToEngineif channel already set; setchannel = nullinonDetachedFromEngineFlutterLogbackAppender.java: GuardsetChannel()from overwriting active channelSwiftOptimizelyFlutterSdkPlugin.swift: Early return inregister(with:)if channel already setOptimizelyFlutterLogger.swift: GuardsetChannel()from overwriting active channelTest plan
flutter test) - 140/140 passed, no regressionsflutter analyze- no issues foundFixes FSSDK-12503
🤖 Generated with Claude Code