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.

Chrome Android rendering is incorrect

See original GitHub issue

Describe the bug

Objects are rendered stretched and distorted on Chrome (and Chrome-based browsers) on Android.

To Reproduce

Steps to reproduce the behavior:

  1. Visit https://cdpn.io/pen/debug/NWYXdoO/d4a556bd02a253cf510b971dfee4772f
  2. Notice on Chrome Desktop (102.0.5005.115 at time of writing) it looks fine:
    chrome-desktop-good-3
  3. Notice it is fine in Firefox Android (102.2.1 at time of writing): firefox-android-good
  4. Notice on Android it is incorrect in Chrome (103.0.5060.129 at time of writing), Edge, Opera, and Samsung Internet, presumably because they all are based on Chrome’s engine, all of them looking like the following: chrome-android-bad

Code

<script src="//unpkg.com/three@0.143.0"></script>

<style>
	html,
	body {
		width: 100%;
		height: 100%;
		padding: 0;
		margin: 0;
	}

	canvas {
		box-sizing: border-box;
		border: 5px solid deeppink;
	}
</style>

<script>
	const renderer = new THREE.WebGLRenderer();
	const canvas = renderer.domElement;
	const sceneW = 980;
	const sceneH = 1851;
	const sceneAspect = sceneW / sceneH;
	let windowAspect = innerWidth / innerHeight;
	renderer.setSize(sceneW, sceneH);


	var camera = new THREE.PerspectiveCamera( 60, window.innerWidth / window.innerHeight, 0.2, 2000 );
	camera.position.set(0,0,10);
	var scene = new THREE.Scene();
	var mesh=new THREE.Mesh(new THREE.BoxGeometry(1,1,1),new THREE.MeshNormalMaterial());
	scene.add(mesh);
	mesh.rotation.set(10/180 * Math.PI, 10/180 * Math.PI, 10/180 * Math.PI)


	function resize() {
		let windowAspect = innerWidth / innerHeight;

		if (windowAspect >= sceneAspect) {
			canvas.width = (window.innerHeight * sceneAspect) ;
			canvas.height = window.innerHeight ;
		} else {
			canvas.width = window.innerWidth ;
			canvas.height = (window.innerWidth / sceneAspect) ;
		}

		var width=canvas.width;
		var height=canvas.height;

		camera.aspect = width / height;
		camera.updateProjectionMatrix();
		renderer.setSize( width, height );
		
		render()
	}


	window.addEventListener('resize', resize);
	renderer.setPixelRatio(window.devicePixelRatio);
	document.body.append(canvas);
	
	function render() {
		renderer.render( scene, camera );
	}
	
	resize();
</script>

Live example

Codepen pen: https://codepen.io/trusktr/pen/NWYXdoO/d4a556bd02a253cf510b971dfee4772f?editors=1000

Debug view: https://cdpn.io/pen/debug/NWYXdoO/d4a556bd02a253cf510b971dfee4772f

Expected behavior

The cube drawing should not be stretched and offset, it should be centered in the view.

Screenshots

See above.

Platform:

  • Device: Pixel 6 Pro
  • OS: Android
  • Browser: Android Chrome, Edge, Opera, and Samsung Internet
  • Three.js version: 143

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
donmccurdycommented, Aug 1, 2022

Feel free to study the problem, but we are asking you to use another place for the investigation and discussion.

1reaction
donmccurdycommented, Aug 1, 2022

I think @Mugen87 is making an educated guess that this is very unlikely to be a bug in the three.js library, and I agree. Under those circumstances, please use other venues for discussion.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix "Aw, Snap!" page crashes and other page loading errors
On your Android phone or tablet, open the Chrome app Chrome . · Tap More More and then New Incognito tab. · In...
Read more >
Why is Google Chrome on Android rendering my table ...
I tried to look at the website in Google Chrome on my desktop computer, but there the table renders fine when i rescale...
Read more >
Rendering bug in Chrome Android? (ok in Chrome Desktop ...
I am able to reproduce the problem only on Chrome-based Android browsers so far. Is there a bug in Chrome?
Read more >
[ Bug ] Text not rendering properly on Chrome on Android #71
Some text on Android Chrome has incorrect spacing.
Read more >
Joe Pea on Twitter: "@Tojiro Can you please take a look at this bug ...
Need to determine if Chrome Android WebGL rendering is incorrect, or if it is an issue in Three.js. https://t.co/NPywVUp3Gs" / Twitter ...
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