From e5259b49ea079ebaa7a128655325f494a36fe100 Mon Sep 17 00:00:00 2001 From: Alexander Biggs Date: Sun, 12 Jun 2022 20:01:03 +0000 Subject: [PATCH] [Ermine][QuickSettings] Fix error from modifying unmodifiable list Dart FIDL lists were made unmodifiable in https://fuchsia-review.googlesource.com/c/fuchsia/+/665177/ which seems to be making this logic crash at runtime. Fixes this error from some logs I saw in an unrelated bug fxb/101341: ``` [00020.831] [30826][60673][flutter_aot_product_runner.cm] ERROR: [flutter/runtime/dart_vm_initializer.cc:41] Unhandled Exception: Unsupported operation: Cannot remove from an unmodifiable list #0 UnmodifiableListMixin.removeAt (dart:_internal/list.dart:164) #1 new SettingsStateImpl.. (package:ermine/src/states/settings_state_impl.dart:325) #2 Function._apply (dart:core-patch/function_patch.dart:11) #3 Function.apply (dart:core-patch/function_patch.dart:34) #4 Action.call (package:mobx/src/core/action.dart:53) #5 runInAction (package:mobx/src/api/action.dart:11) #6 new SettingsStateImpl. (package:ermine/src/states/settings_state_impl.dart:313) #7 ChannelService.start (package:ermine/src/services/settings/channel_service.dart:39) #8 Future.wait. (dart:async/future.dart:522) #9 SettingsStateImpl.start (package:ermine/src/states/settings_state_impl.dart:387) ``` Change-Id: I5adffdec4e64beafc2cc97da5e23197e4ec2e298 Reviewed-on: https://fuchsia-review.googlesource.com/c/experiences/+/684597 Reviewed-by: Sanjay Chouksey Reviewed-by: Charles Whitten Commit-Queue: Alexander Biggs --- .../ermine/shell/lib/src/states/settings_state_impl.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/experiences/session_shells/ermine/shell/lib/src/states/settings_state_impl.dart b/src/experiences/session_shells/ermine/shell/lib/src/states/settings_state_impl.dart index ab1b3ca2dae6..33c4ac5ca10b 100644 --- a/src/experiences/session_shells/ermine/shell/lib/src/states/settings_state_impl.dart +++ b/src/experiences/session_shells/ermine/shell/lib/src/states/settings_state_impl.dart @@ -318,7 +318,10 @@ class SettingsStateImpl with Disposable implements SettingsState, TaskService { List channels; if (currentChannel.isNotEmpty) { if (channelService.channels.contains(currentChannel)) { - channels = channelService.channels; + // FIDL messages are unmodifiable so we need to copy the list of + // channels here. + channels = List.from(channelService.channels); + int index = channels.indexOf(currentChannel); if (index != 0) { channels