Skip to content

Conversation

@ManlyMarco
Copy link
Member

Adding or removing Logger.Listeners and Logger.Sources can cause exceptions if some other thread is currently enumerating these lists, e.g. when calling Logger.Log. This usually causes unexpected crashes in whatever code was trying to log something at an unfortunate time. I noticed it can also lead to a listener not getting some log messages.

The changes result in sending log events being slightly faster with no allocations (saves a few ms overall), but Add/Remove operations are slightly slower (still 0 ms overall).

Fixes #655

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Member Author

@ManlyMarco ManlyMarco left a comment

Choose a reason for hiding this comment

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

After testing in a bunch of different games this seems to work perfectly fine so I'll just merge it in preparation for an upcoming BepInEx update.

@ManlyMarco ManlyMarco merged commit a5f5b9c into v5-lts Aug 29, 2023
@ManlyMarco ManlyMarco deleted the v5-threadsafe-logger branch August 29, 2023 15:25
aldelaro5 added a commit to aldelaro5/BepInEx that referenced this pull request Sep 15, 2024
aldelaro5 added a commit to aldelaro5/BepInEx that referenced this pull request Sep 16, 2024
aldelaro5 added a commit to aldelaro5/BepInEx that referenced this pull request Sep 17, 2024
Originally pull request BepInEx#656

Co-authored-by: ManlyMarco <[email protected]>
aldelaro5 added a commit to aldelaro5/BepInEx that referenced this pull request Sep 17, 2024
Originally pull request BepInEx#656

Co-authored-by: ManlyMarco <[email protected]>
js6pak pushed a commit that referenced this pull request Sep 17, 2024
Originally pull request #656

Co-authored-by: ManlyMarco <[email protected]>
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