Skip to content

fix: avoid concurrent modification during event dispatch#128

Merged
LichKing-2234 merged 3 commits into
mainfrom
mian-fav2
Apr 13, 2026
Merged

fix: avoid concurrent modification during event dispatch#128
LichKing-2234 merged 3 commits into
mainfrom
mian-fav2

Conversation

@ZGaopeng

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to prevent ConcurrentModificationError when event handlers are added/removed during Iris event dispatch.

Changes:

  • Update event dispatch to iterate over a snapshot of handlers (toList) and skip handlers removed mid-dispatch.
  • Make ScopedObjects.clear() iterate over a snapshot of pool.values to avoid concurrent modification during disposal.
  • Add a regression test reproducing add/remove-during-dispatch scenarios.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
test/repro_concurrent_modification_test.dart Adds a repro/regression test for handler add/remove during dispatch.
lib/src/scoped_objects.dart Snapshots pool.values during clear() to avoid mutation while disposing.
lib/src/platform/iris_method_channel_interface.dart Changes handler storage to copy-on-write Set updates and adjusts disposal behavior.
lib/src/iris_method_channel.dart Uses a handler snapshot during dispatch and adds exception handling around dispatch.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/src/iris_method_channel.dart
Comment thread lib/src/platform/iris_method_channel_interface.dart
Comment thread lib/src/platform/iris_method_channel_interface.dart Outdated
Comment thread test/repro_concurrent_modification_test.dart Outdated
Comment thread test/repro_concurrent_modification_test.dart Outdated
Comment thread test/repro_concurrent_modification_test.dart

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/repro_concurrent_modification_test.dart
Comment thread test/repro_concurrent_modification_test.dart
Comment thread lib/src/platform/iris_method_channel_interface.dart Outdated
Comment thread lib/src/iris_method_channel.dart
@LichKing-2234 LichKing-2234 merged commit b275c0f into main Apr 13, 2026
8 of 26 checks passed
@LichKing-2234 LichKing-2234 deleted the mian-fav2 branch April 13, 2026 06:46
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.

3 participants