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: Enforce minimum buffer size on resize #4554

Merged

Conversation

hugolafis
Copy link
Contributor

Type of change

Bug

Jira ticket 📘

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

Description 📝

This change enforces a minimum buffer size of 1 pixel in both dimensions to ensure that if the canvas element is contained within a resizable element, it never ends up with a width or height of 0, which causes GL errors, e.g.:
[.WebGL-000012EC00717100] GL_INVALID_FRAMEBUFFER_OPERATION: Framebuffer is incomplete: Attachment has zero size.

How has this been tested? 🔍

I've tested this in situ on an application which has the canvas contained within a flexible container, which fills the available remaining space, and also on the Reveal example viewer. The issue arises when the canvas element gets shrunk down so that it's width or height end up at 0.

Test instructions ℹ️

If you modify the returned template at the end of the Viewer.tsx class, you can replicate this by expanding the resizable div to full width, the GL errors will be thrown in the console.

With this fix no errors will be thrown.

  return (
    <div style={{ width: '100%', height: '100%', position: 'fixed', display: 'flex' }}>
      <div style={{ width: '50%', height: '100%', resize: 'both', overflow: 'scroll' }}></div>
      <CanvasWrapper ref={canvasWrapperRef} />
    </div>
  );

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 30, 2024 09:50
Copy link

codecov bot commented May 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.30%. Comparing base (dfe17bb) to head (8e7f55b).
Report is 290 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4554      +/-   ##
==========================================
- Coverage   71.10%   69.30%   -1.81%     
==========================================
  Files         378      389      +11     
  Lines       38591    40262    +1671     
  Branches     2774     2810      +36     
==========================================
+ Hits        27442    27905     +463     
- Misses      11039    12243    +1204     
- Partials      110      114       +4     
Files Coverage Δ
viewer/packages/rendering/src/ResizeHandler.ts 96.38% <100.00%> (+1.26%) ⬆️

... and 86 files with indirect coverage changes

@christjt christjt enabled auto-merge (squash) May 30, 2024 12:02
@christjt christjt merged commit 9fb5494 into cognitedata:master May 30, 2024
13 of 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.

3 participants