Skip to content

fix: user context menu opens in an incorrect position on screen - #8775

Merged
Maurizio-dcl merged 5 commits into
devfrom
fix/8768-user-context-menu-opens-in-an-incorrect-position-on-screen
Jun 3, 2026
Merged

fix: user context menu opens in an incorrect position on screen#8775
Maurizio-dcl merged 5 commits into
devfrom
fix/8768-user-context-menu-opens-in-an-incorrect-position-on-screen

Conversation

@Maurizio-dcl

@Maurizio-dcl Maurizio-dcl commented May 14, 2026

Copy link
Copy Markdown
Contributor

Pull Request Description

Fix #8768 and #8767

What does this PR change?

Moved backgroundWorldRect calculation from OnViewInstantiated() to OnBeforeViewShow() in GenericContextMenuController

Test Instructions

These steps need to be verified in both windowed and fullscreen mode, and on different resolutions as well.

Test Steps

  1. Open the minimap context menu
  2. Verify the menu opens in the correct place (directly right of the three-dots button)
  3. Close the minimap context menu
  4. Open a user's context menu (right-click on their avatar)
  5. Verify the menu opens in the correct position (close to the cursor / avatar and on the left or right depending on how close the avatar is to the screen borders)

Quality Checklist

  • Changes have been tested locally
  • Documentation has been updated (if required)
  • Performance impact has been considered
  • For SDK features: Test scene is included

Code Review Reference

Please review our Branch & PR Standards before submitting. It explains the automated review flow, QA/DEV approval requirements, and what each label does — especially useful for first-time contributors.

- Moved backgroundWorldRect calculation from OnViewInstantiated() to OnBeforeViewShow()
@Maurizio-dcl Maurizio-dcl self-assigned this May 14, 2026
@Maurizio-dcl
Maurizio-dcl requested review from a team as code owners May 14, 2026 13:18
@github-actions
github-actions Bot requested a review from anicalbano May 14, 2026 13:18
@claude

This comment has been minimized.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auto-approved by Claude — simple fix/chore with no blocking issues. QA approval is still required.

@claude

claude Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Claude encountered an error —— View job


Review

  • Gather context and read changed files
  • Analyze the fix and root cause
  • Check for blocking issues
  • Post final review

@claude

This comment has been minimized.

@m3taphysics

Copy link
Copy Markdown
Contributor

PR #8775, run #26229057670

Builds: Windows change, Windows baseline, macOS change, macOS baseline

Framework 13 i7

Metric Change Baseline Delta Improvement
Samples 2700 2700
CPU average 33.3 ms 33.3 ms 0.0 ms -0.0%
CPU 1% worst 33.6 ms 33.6 ms 0.0 ms -0.1%
CPU 0.1% worst 35.1 ms 34.7 ms 0.5 ms -1.3%
GPU average 7.8 ms 7.5 ms 0.3 ms -3.4% 🔴
GPU 1% worst 20.2 ms 20.5 ms -0.3 ms 1.5%
GPU 0.1% worst 23.9 ms 24.9 ms -1.0 ms 3.9% 🟢

@claude

This comment has been minimized.

@m3taphysics

Copy link
Copy Markdown
Contributor

PR #8775, run #26761841566

Builds: Windows change, Windows baseline, macOS change, macOS baseline

Framework 13 i7

Values are the median across 3 run(s); the (min–max) range shows how much the runs varied. A metric is only flagged when the change is larger than both the 3% threshold and that run-to-run variation.

Metric Change Baseline Delta Improvement
Samples 2700 (×3) 2699 (×3)
CPU average 33.3 ms 33.3 ms -0.0 ms 0.0%
CPU 1% worst 33.9 ms (33.8–34.4) 34.7 ms (33.8–34.8) -0.8 ms 2.2%
CPU 0.1% worst 36.2 ms (35.3–39.8) 44.7 ms (38.5–49.2) -8.6 ms 19.1%
GPU average 7.7 ms (7.4–7.7) 8.3 ms (7.5–8.5) -0.6 ms 7.3%
GPU 1% worst 20.0 ms (19.3–20.0) 18.2 ms (17.7–19.5) 1.8 ms -10.1% 🔴
GPU 0.1% worst 25.3 ms (22.8–25.8) 23.9 ms (22.7–25.8) 1.5 ms -6.2%
Exceptions logged 14 20 -6 🟢

@claude

claude Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Claude finished @Maurizio-dcl's task in 3m 7s —— View job


Review

  • Gather context and read changed files
  • Analyze the fix and root cause
  • Check for blocking issues
  • Post final review

Root-Cause Assessment

Problem: Context menu opens at an incorrect position across different resolutions and windowed/fullscreen modes.

Root cause vs symptom: This is a root-cause fix. backgroundWorldRect (the boundary rect used in GetControlsPosition, GetFallbackDirections, and AdjustSubmenuPositionToFitBounds) was computed once in OnViewInstantiated(), which fires only at view creation. Any resolution/window-mode change after that left the rect permanently stale. Moving the calculation to OnBeforeViewShow() recomputes it on every open.

The viewInstance!.gameObject.SetActive(true) guard (latest commit a5f3ee69) ensures the view is active before calling GetWorldCorners — on an inactive GameObject, GetWorldCorners returns zero/invalid coordinates. This is the correct approach (cleaner than Canvas.ForceUpdateCanvases() and directly addresses the cause). The secondary change — reading from viewRectTransform (the full-screen canvas root) instead of BackgroundCloseButton.GetComponent<RectTransform>() — is also correct; the canvas root is the proper screen-boundary rect.


Blocking Issues

None found.

Behavioral note (informational, not blocking): Removing BackgroundCloseButton removed the viewInstance!.BackgroundCloseButton.Button.OnClickAsync(ct) source from WaitForCloseIntentAsync (GenericContextMenuController.cs:891). The menu now closes via internalCloseTask (item click, TriggerContextMenuClose) or the caller's inputData.CloseTask. All three active callers — GenericUserProfileContextMenuController, ChatOptionsContextMenuController, CommunityPlayerEntryContextMenu, CommunityContextMenuController — pass an explicit closeMenuTask, so the close contract is fully satisfied. This change is intentional per d7d79c15. QA should confirm click-outside-to-close behaviour works for both the minimap and user context menus.


Summary

Clean, minimal fix. Stale-rect root cause correctly addressed by moving computation to OnBeforeViewShow(). Pre-activating the GameObject before reading world coordinates is the right guard. Removal of BackgroundCloseButton is intentional and all callers supply their own close tasks. PASS.


REVIEW_RESULT: PASS ✅
COMPLEXITY: SIMPLE
COMPLEXITY_REASON: Single-file UI lifecycle change moving a RectTransform boundary calculation between controller lifecycle methods, plus removal of a full-screen close-button overlay from view and prefab.
QA_REQUIRED: YES

@m3taphysics

Copy link
Copy Markdown
Contributor

PR #8775, run #26808076333

Builds: Windows change, Windows baseline, macOS change, macOS baseline

Framework 13 i7

Values are the median across 3 run(s); the (min–max) range shows how much the runs varied. A metric is only flagged when the change is larger than both the 3% threshold and that run-to-run variation.

Metric Change Baseline Delta Improvement
Samples 2700 (×3) 2700 (×3)
CPU average 33.3 ms 33.3 ms 0.0 ms -0.0%
CPU 1% worst 34.3 ms (33.9–34.7) 33.5 ms (33.5–33.5) 0.8 ms -2.3%
CPU 0.1% worst 37.6 ms (36.9–46.0) 34.5 ms (34.2–35.2) 3.1 ms -9.0%
GPU average 7.5 ms (7.4–8.1) 8.8 ms (8.5–9.4) -1.3 ms 15.3% 🟢
GPU 1% worst 19.5 ms (19.5–21.1) 18.2 ms (17.5–19.3) 1.3 ms -7.3%
GPU 0.1% worst 26.1 ms (23.7–27.9) 24.7 ms (23.2–25.5) 1.4 ms -5.6%
Exceptions logged 16 14 +2 🔴

@DafGreco DafGreco 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.

✔️ PR reviewed and approved by QA on both platforms following instructions playing both happy and un-happy path

Regressions for this ticket had been performed in order to verify that the normal flow is working as expected:

  • [✔️ ] Backpack and wearables in world
  • [✔️ ] Emotes in world and in backpack
  • [ ✔️ ] Teleport with map/coordinates/Jump In
  • [ ✔️ ] Chat and multiplayer
  • [ ✔️ ] Profile card
  • [✔️ ] Settings

Evidence

20260603-0806-30.6332880.mp4

@Maurizio-dcl
Maurizio-dcl merged commit 094bd1b into dev Jun 3, 2026
17 of 19 checks passed
@Maurizio-dcl
Maurizio-dcl deleted the fix/8768-user-context-menu-opens-in-an-incorrect-position-on-screen branch June 3, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[QA] Explorer | User context menu opens in an incorrect position on screen

4 participants