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.

Disabling video auto scaling requires workaround

See original GitHub issue

OS platform / Browser

Windows 10, Chrome 105

melonJS version

v13.0.0

Bug description

Video always auto scale, even if settings.scale != 'auto'

When not specified, setting.scaleMethod defaults to fit, forcing settings.autoScale to true ((anything || true) == true) https://github.com/melonjs/melonJS/blob/313af5c746d25d8d0d33986bf631f3e18843e857/src/video/video.js#L237-L238

Setting setting.scale to a value bigger than 1 and changing setting.scaleMethod to an empty string (or any string that doesn’t math the if above) still doesn’t work because, for some reason, the canvas element comes with it’s width/height set to width * scale/height * scale instead of just width/height and without style="width:...;height:...;", so everything drawn in the canvas is smaller than it should.

Steps to reproduce the bug

video.init(64, 64, {
  parent: 'screen',
  scale: 8
})

Workaround

The only way to disable auto scaling and make the scaling work as intended is to set setting.scale to 1 and then call video.scale() with the desired scale size

video.init(64, 64, {
  parent: 'screen',
  scale: 1, // Must be 1 to force canvas size to the correct width/height (64x64 in this case)
  scaleMethod: '' // Any invalid string value works
})

video.scale(8, 8) // Scale canvas to the intended size

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
obiotcommented, Aug 9, 2022

Oh no, you got me! fakes death with hand in chest while falling to the ground in the most dramatic and unrealistic death pose ever

😃😃😃😃

0reactions
obiotcommented, Aug 9, 2022

yes, we had some refactoring going out around the renderer(s) to align both the canvas and WebGL one.

But cool then, I’ll close back this one 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Auto Scaling Terminate Unhealthy Instance - AWS
I have an Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling group set up, but it's not terminating an unhealthy Amazon EC2 instance....
Read more >
How to Disable Scaling in Apps on Windows 10 [Tutorial]
Your browser can't play this video. ... How to Fix Scaling for Blurry Apps in Windows 10: Full HD or 4K monitors are...
Read more >
Windows scaling issues for high-DPI devices - Microsoft Support
Right-click the application, select Properties, select the Compatibility tab, and then select the Disable display scaling on high DPI settings check box.
Read more >
How to turn off autoplay videos on Facebook, Twitter, Firefox ...
Automatic video play is a feature that, while nice to have when it's ... Keep in mind that you'll need to adjust these...
Read more >
Enabling or disabling participants video - Zoom Support
Participants video allows the meeting participant to start a meeting with video turned on. If the participant video is disabled, the...
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