Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Unable to see other user's passport card #1996

Merged
merged 4 commits into from
Sep 11, 2024

Conversation

sandrade-dcl
Copy link
Contributor

@sandrade-dcl sandrade-dcl commented Sep 9, 2024

What does this PR change?

Fix #1786

There were some cases in which the passport card of other users couldn't be open. The option "view profile" didn't appear when hovering over them.

The problem was that we were never releasing the collider of none of the remote avatars, so each time a new avatar was being spawned, a new collider was being added as child. If this happened several times with the same avatar, we were accumulating several colliders for the same game object and it was causing conflicts in the click detection.

How to test the changes?

  1. There must be several users connected in the same place.
  2. Hover over each of them and check that you can click on all of them (you will see the "View profile" message).
  3. Some of the users should jump into another far scene and jump back into the current one.
  4. Repeat the steps 2 and 3 and check that you can ALWAYS click on the rest of avatars.

Our Code Review Standards

https://github.com/decentraland/unity-renderer/blob/master/docs/code-review-standards.md

Summary by CodeRabbit

  • New Features

    • Enhanced collider management with the introduction of a specialized RemoteAvatarCollider type for improved functionality related to remote avatars.
  • Bug Fixes

    • Improved type safety and functionality in collider handling, ensuring more reliable operations when adding and removing colliders.
  • Refactor

    • Streamlined the RemoteEntities class to focus on RemoteAvatarCollider, enhancing maintainability and encapsulation of collider logic.

@sandrade-dcl sandrade-dcl self-assigned this Sep 9, 2024
Copy link
Contributor

github-actions bot commented Sep 9, 2024

badge

Windows and Mac build successfull in Unity Cloud! You can find a link to the downloadable artifact below.

Name Link
Commit 1049d11
Logs https://github.com/decentraland/unity-explorer/actions/runs/10808240277
Download Windows https://github.com/decentraland/unity-explorer/suites/28244450962/artifacts/1918619425
Download Mac https://github.com/decentraland/unity-explorer/suites/28244450962/artifacts/1918613050
Built on 2024-09-11T09:28:30Z

Copy link

coderabbitai bot commented Sep 9, 2024

Walkthrough

The pull request introduces significant changes to the RemoteEntities class, specifically updating the type of colliders stored in the collidersByWalletId dictionary from Collider to RemoteAvatarCollider. This change enhances type safety and allows for the use of methods specific to RemoteAvatarCollider. Additionally, adjustments are made in methods like TryRemove and CreateCharacter to reflect the new collider type, ensuring a consistent approach to managing these entities.

Changes

File Change Summary
Explorer/Assets/DCL/Multiplayer/Profiles/Entities/RemoteEntities.cs Updated collidersByWalletId from Dictionary<string, Collider> to Dictionary<string, RemoteAvatarCollider>; modified remoteAvatarColliderPool type accordingly.

Assessment against linked issues

Objective Addressed Explanation
Unable to see other user's passport card (#1786) The changes do not directly address UI issues related to profile visibility.

Possibly related PRs

Suggested labels

no QA needed

Poem

🐇 In the meadow where avatars play,
Colliders now dance in a new way.
RemoteAvatar shines, a sight to behold,
With safety and function, their stories unfold.
Hopping along, we celebrate this cheer,
For every new change brings us closer, my dear! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Outside diff range, codebase verification and nitpick comments (1)
Explorer/Assets/DCL/Multiplayer/Profiles/Entities/RemoteEntities.cs (1)

92-95: Consider Adding Error Handling and Logging

The TryRemove and RemoveGlobalEntityAssociation methods lack explicit error handling or logging. In a multiplayer environment, it's crucial to ensure these operations are robust against errors and race conditions. Consider adding error handling or logging to monitor these operations effectively.

  • TryRemove method in RemoteEntities.cs
  • RemoveGlobalEntityAssociation method in EntityCollidersGlobalCache.cs
Analysis chain

Verify the removal logic for consistency and error handling.

The TryRemove method updates the collidersByWalletId dictionary and releases resources using remoteAvatarColliderPool. It's crucial to ensure that these operations are atomic and error-free, especially in a multiplayer environment where race conditions can occur.

Consider adding error handling or logging to monitor these operations, and verify that the RemoveGlobalEntityAssociation method handles exceptions or unusual states gracefully.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the error handling in the removal logic.

# Test: Search for error handling patterns in the TryRemove method.
rg --type cs -A 5 $'TryRemove' Explorer/Assets/DCL/Multiplayer/Profiles/Entities/RemoteEntities.cs

Length of output: 541


Script:

#!/bin/bash
# Search for try-catch blocks and logging within the TryRemove method.
rg --type cs -A 10 'TryRemove' Explorer/Assets/DCL/Multiplayer/Profiles/Entities/RemoteEntities.cs | rg -i 'try|catch|log'

# Search for the implementation of the RemoveGlobalEntityAssociation method to check for error handling.
ast-grep --lang csharp --pattern 'RemoveGlobalEntityAssociation($_)' --search-implementation

Length of output: 751


Script:

#!/bin/bash
# Correct the ast-grep command to find the implementation of the RemoveGlobalEntityAssociation method.
ast-grep --lang csharp --pattern 'RemoveGlobalEntityAssociation($_)' 

Length of output: 70


Script:

#!/bin/bash
# Search for the definition of the RemoveGlobalEntityAssociation method across the codebase.
rg --type cs 'RemoveGlobalEntityAssociation' -A 5

Length of output: 1527

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ea3c2bf and ceec9e1.

Files selected for processing (1)
  • Explorer/Assets/DCL/Multiplayer/Profiles/Entities/RemoteEntities.cs (3 hunks)
Additional context used
Path-based instructions (1)
Explorer/Assets/DCL/Multiplayer/Profiles/Entities/RemoteEntities.cs (2)

Pattern **/*.cs: Review the code for heap allocations and suggest potential improvements to avoid runtime allocations.


Pattern **/*.cs: Review the code for specific unity engine optimizations and suggest potential improvements.

Copy link

@Ludmilafantaniella Ludmilafantaniella left a comment

Choose a reason for hiding this comment

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

🟢 Fix verified and approved by QA. Tested on Mac Sonoma 14.1

@sandrade-dcl sandrade-dcl merged commit 6602014 into main Sep 11, 2024
5 checks passed
@sandrade-dcl sandrade-dcl deleted the fix/unable-to-click-on-other-avatars branch September 11, 2024 12:18
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.

[QA] Unable to see other user's passport card
3 participants