question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong canvas height calculation

See original GitHub issue

This is probably the same class of bug as #1081.

I use xterm.js integrated in a fixed size area, and tell xterm.js to fit in there (it’s actually in a PhosphoreJS widget/view/tab/dockable thingy). When playing with the browser zoom level, and thus the window.devicePixelRatio, it happens sometimes that the bottom of the terminal is outside the allocated space (the area of the parent div). I made a reproducer by modifying the demo application, it can be found at

https://github.com/simark/xterm.js/tree/repro-canvas-height

To run, build and start the demo as usual (npm run start). At 100% zoom level, this is what I see, which is right:

100

The terminal container is a 500px x 500px div. The pink in the back is a div with width 100% and height 500px I have put so we can see if the terminal’s height is greater than the allocated 500px. We see a bit of pink below the terminal, probably because xterm.js only uses the space required to fit the lines that fit. Since there isn’t enough space to fit another line, it just doesn’t use that space. That seems right.

With the zoom level at 67%, I see this:

67

As you can see, the terminal goes beyond the allocated height. When integrated in an application with other widgets, it means that the terminal will overlap on something else, or the bottom (the last few lines) will be hidden.

Details

  • Browser and browser version: Chromium Version 62.0.3202.94 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit) as well as Firefox 57.0 on Ubuntu 16.04
  • OS version: Ubuntu 16.04.
  • xterm.js version: v3 (see commit in the reproducer branch)

Steps to reproduce

  1. Checkout branch https://github.com/simark/xterm.js/tree/repro-canvas-height
  2. npm run start
  3. Open http://localhost:3000, zoom out to 67%, reload if needed for the layout to readjust

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
simarkcommented, Dec 20, 2017

Ok thanks! I’ll try to upgrade to today’s master and test soon.

0reactions
mofuxcommented, Dec 20, 2017

Should be fixed by #1157

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting wrong canvas height - Stack Overflow
As you are not setting the size of the canvas element its bitmap will default to ... First, remove the width and height...
Read more >
Wrong canvas width calculation · Issue #1081 · xtermjs/xterm.js
In Renderer.ts::onResize the character width is floored, which makes it 7px. The total canvas size is then computed as the number of columns ......
Read more >
HTML canvas height Attribute - W3Schools
The height attribute specifies the height of the <canvas> element, in pixels. Tip: Use the width attribute to specify the width of the...
Read more >
Window.devicePixelRatio - Web APIs | MDN
A <canvas> can appear too blurry on retina screens. Use window.devicePixelRatio to determine how much extra pixel density should be added to ...
Read more >
Configure a WebGL Canvas size - Unity - Manual
To do so, in the index.html file of the WebGL template, set the Unity Instance configuration variable to false: matchWebGLToCanvasSize=false . When this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found