Skip to content

Comments

Fix thread-safety issues in concurrent code paths#2054

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/review-non-thread-safe-code
Draft

Fix thread-safety issues in concurrent code paths#2054
Copilot wants to merge 4 commits intomasterfrom
copilot/review-non-thread-safe-code

Conversation

Copy link

Copilot AI commented Jan 20, 2026

Fixes thread-safety issues in classes where async tasks write to shared state that is read by the main/render thread.

Changes

  • ProfileViewerScreen: Volatile fields (hypixelProfile, playerProfile, entity, etc.) for visibility of async writes to render thread
  • BackpackPreview: AtomicReferenceArray for storages to guarantee visibility and atomic operations across threads
  • ItemRepository: Volatile itemsImported/filesImported flags for visibility across async loading and synchronous reads

Scope

Only code with verified concurrent access has been modified - specifically cases where:

  • Async CompletableFuture tasks write to fields/collections
  • Main or render thread reads those same fields/collections
  • Without proper synchronization, visibility guarantees are not met

Code using CompletableFutures but without actual concurrent access to shared mutable state (e.g., sequential event handlers, serialized task queues) has not been modified.

Original prompt

Review and identify non-thread-safe code that could lead to race conditions or have unwanted effects. Review the use of concurrency, completable futures, and virtual threads.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@LifeIsAParadox LifeIsAParadox added the wip This PR is a work in progress label Jan 20, 2026
@kevinthegreat1
Copy link
Collaborator

Ok I didn't know it was going to make a pr...

Copilot AI and others added 2 commits January 20, 2026 04:11
Co-authored-by: kevinthegreat1 <92656833+kevinthegreat1@users.noreply.github.com>
Co-authored-by: kevinthegreat1 <92656833+kevinthegreat1@users.noreply.github.com>
@kevinthegreat1
Copy link
Collaborator

Don't make just random code thread-safe. Only check for thread safety in actual concurrent code that is being accessed by multiple threads.

Copilot AI changed the title [WIP] Review concurrency and identify non-thread-safe code Fix thread-safety issues in concurrent code paths Jan 20, 2026
Copilot AI requested a review from kevinthegreat1 January 20, 2026 04:18
Copy link
Collaborator

@kevinthegreat1 kevinthegreat1 left a comment

Choose a reason for hiding this comment

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

Don't make just random code thread-safe. Only check for thread safety in actual concurrent code that is being accessed by multiple threads.

…ently

Co-authored-by: kevinthegreat1 <92656833+kevinthegreat1@users.noreply.github.com>
Copy link
Author

Copilot AI commented Jan 20, 2026

Don't make just random code thread-safe. Only check for thread safety in actual concurrent code that is being accessed by multiple threads.

Reverted changes to code without actual concurrent access. Kept only:

  • ProfileViewerScreen: async writes, render thread reads
  • BackpackPreview: async writes, render thread reads
  • ItemRepository: async writes, main thread reads

Reverted DiscordRPCManager, SecretsTracker, and SkyblockerWebSocket (events/calls are sequential, no real concurrency).

Commit: 11a3eaa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wip This PR is a work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants