Commit 9da6774
[FSSDK-12503] fix: guard static MethodChannel from multi-engine overwrite (#103)
* fix: guard static MethodChannel from multi-engine overwrite (Android)
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>
* fix: guard logger channel from multi-engine overwrite (Android)
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>
* fix: guard static MethodChannel from multi-engine overwrite (iOS)
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>
* fix: guard logger channel from multi-engine overwrite (iOS)
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>
* refactor: split setChannel into setChannel/clearChannel for logger channels
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>
* fix: add iOS engine detach cleanup and enforce private channel access
Add detachFromEngine(for:) to iOS plugin so channel is cleaned up when
the engine detaches, matching Android's onDetachedFromEngine behavior.
Make FlutterLogbackAppender.channel private to enforce use of
setChannel/clearChannel accessors.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 305b5ec commit 9da6774
4 files changed
Lines changed: 32 additions & 7 deletions
File tree
- android/src/main/java/com/optimizely/optimizely_flutter_sdk
- ios/Classes
Lines changed: 9 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
| |||
Lines changed: 6 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
| |||
232 | 235 | | |
233 | 236 | | |
234 | 237 | | |
| 238 | + | |
235 | 239 | | |
236 | 240 | | |
237 | 241 | | |
238 | 242 | | |
239 | 243 | | |
240 | 244 | | |
241 | 245 | | |
242 | | - | |
243 | | - | |
| 246 | + | |
| 247 | + | |
244 | 248 | | |
245 | 249 | | |
246 | 250 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
53 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
54 | 63 | | |
55 | 64 | | |
56 | 65 | | |
| |||
0 commit comments