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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DefaultCameraManager event listener leak #4509

Merged

Conversation

hugolafis
Copy link
Contributor

Type of change

Bug

Jira ticket 馃摌

https://cognitedata.atlassian.net/browse/

Description 馃摑

This PR deregisters an event listener that is placed on the document when creating a tween animation, but is currently only removed if the tween is cancelled. There is now a call to deregister the event listener when the tween completes as well.

How has this been tested? 馃攳

I've tested this by creating a viewer, calling a fit to view method on the DefaultCameraManager, then disposing of the viewer. After this you should be able to take a chrome heap snapshot to see if the WebGL context is still reachable from the window.

Test instructions 鈩癸笍

Create a viewer (using the DefaultCameraManager)
Call the method to fit the camera to view
Dispose of the viewer
Take a chrome heap snapshot and search for Detached WebGL2RenderingContext

Viewer.tsx

      viewer = new Cognite3DViewer(viewerOptions);
      const bbox = new THREE.Box3(new THREE.Vector3(-0.5, -0.5, -0.5), new THREE.Vector3(0.5, 0.5, 0.5));

      viewer.fitCameraToBoundingBox(bbox, 0, 1);
      viewer.dispose();

      viewer = new Cognite3DViewer(viewerOptions);

Checklist 鈽戯笍

  • I am proud of this feature.
  • I have performed a self-review of my own code.
  • I have added PR type (Feat, Bug, Chore, Test, Docs, Style, Refactor) to the PR title.
  • I have manually tested this for different scenarios (different models, formats, devices, browsers).
  • I have commented my code in hard-to-understand areas.
  • I have made corresponding changes to the public documentation.
  • I have added unit and visuals tests to prove that my feature works to the best of my ability.
  • I have refactored the code for readability to the best of my ability.
  • I have checked that my changes do not introduce regressions in the public documentation.
  • I have outlined any known defects / lacking capabilities in the contents of this PR.
  • I have listed any remaining work that should follow this PR in the description or jira/miro/etc.
  • I have added TSDoc to any public facing changes.
  • I have added "developer documentation" in any package README.md that is related / applicable to this PR.
  • I have noted down and am currently tracking any technical debt introduced in this PR.
  • I have thoroughly thought about the architecture of this implementation.
  • I have asked peers to test this feature.

@hugolafis hugolafis requested a review from a team as a code owner May 16, 2024 13:45
Copy link

codecov bot commented May 16, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 69.33%. Comparing base (dfe17bb) to head (c4361c1).
Report is 252 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4509      +/-   ##
==========================================
- Coverage   71.10%   69.33%   -1.78%     
==========================================
  Files         378      389      +11     
  Lines       38591    40241    +1650     
  Branches     2774     2809      +35     
==========================================
+ Hits        27442    27900     +458     
- Misses      11039    12254    +1215     
+ Partials      110       87      -23     
Files Coverage 螖
...ackages/camera-manager/src/DefaultCameraManager.ts 65.71% <50.00%> (-0.01%) 猬囷笍

... and 57 files with indirect coverage changes

@christjt christjt enabled auto-merge (squash) May 21, 2024 11:13
@christjt christjt merged commit e7a707d into cognitedata:master May 21, 2024
14 checks passed
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.

None yet

2 participants