VH and VW are View height and View width. as such - they are the measurments of the screen sans any console url navigator. the View.
the reason you are getting white space is you are Calculating a new number... which is slightly smaller than the entire screen - by 6px, because you are shrinking 100% view coverage by subtracting px's from both height and width.
margin on the canvas also is a reason for you seeing white space....
margin ->border ->padding ->content is the nesting for that model. margin is just adding space to the element - which is space AROUND the element {space directly OUTSIDE the border} - (margins combine with other margins) - where padding increases space inside of the border of the div - margin increase space right outside the border of the targeted element.
so if you're goal is to fit it to 100% of the screen. you just need VH/VW to be set to 100; and nix the margin.
if you're goal is to fit it into 100% of the div container it is in... VH VW are the wrong measure units to use for that.
here is some code I did on codepen to test.
this results in the canvas covering the screen, leaving no space other than the canvas.
html
<html>
<body>
<canvas class="canvas" id="canvas"></canvas>
</body>
</html>
css
* {
padding: 0;
margin: 0;
border: 0;
}
.canvas {
width: 100vw;
height: 100vh;
}
js test
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = "black";
ctx.fillRect(0,0,canvas.width,canvas.height);