Chrome unable to render WebGL content

My website has a webgl background that experiences lag in Chrome for Mac. All other browsers, including Chrome for Windows, load the website correctly. I have noticed that setting the force color profile to sRGB on Chrome fixes the issue on my personal computer, but the problem persists for other visitors. Is there a solution to this? Here is a JSFiddle link: https://jsfiddle.net/ovmy52uc/ Here is the code snippet:

var SEPARATION = 100, AMOUNTX = 50, AMOUNTY = 50;
var container;
var camera, scene, renderer;
var particles, particle, count = 0;
var mouseX = 0, mouseY = 0;
var windowHalfX = window.innerWidth / 2;
var windowHalfY = window.innerHeight / 2;
// Initialization function 
function init() {
container = $('.webgl .background');
camera = new THREE.PerspectiveCamera( 75, window.innerWidth / 
window.innerHeight, 1, 10000 );
camera.position.z = 1000;
scene = new THREE.Scene();
particles = new Array();
var PI2 = Math.PI * 2;
var material = new THREE.SpriteCanvasMaterial( {
color: 0xffffff,
program: function ( context ) {
context.beginPath();
context.arc( 0, 0, 0.5, 0, PI2, true );
context.fill();
}
} );

// Additional code for particle generation and rendering

renderer = new THREE.CanvasRenderer();
$(container).append( renderer.domElement );
document.addEventListener( 'mousemove', onDocumentMouseMove, false );
document.addEventListener( 'touchstart', onDocumentTouchStart, false 
);
document.addEventListener( 'touchmove', onDocumentTouchMove, false );

window.addEventListener( 'resize', onWindowResize, false );
}

// Function to handle window resize
function onWindowResize() {
// Code for resizing
}

// More functions for mouse and touch input handling

// Main animation loop
function animate() {
requestAnimationFrame( animate );
render();
}

// Rendering function with particle movement logic

When loading the page outside of the JSFiddle, it becomes even slower on Chrome for Mac. Any help would be appreciated. Thank you.

Answer №1

There are a couple of factors contributing to the lag you're experiencing.
Firstly, consider removing the following line:

renderer.setPixelRatio( window.devicePixelRatio );

This may be causing your canvas resolution to be too high on high DPI screens.

Additionally, examine the for loops in your render function as they could also be contributing to the lag.

Answer №2

When working with the CanvasRenderer, it's important to note that you're utilizing a Canvas 2D rendering context rather than WebGL. Consider switching to the WebGLRenderer for improved performance and efficiency in your projects.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Issue #2032: AJAX causing OpenFlashChart error; solution found with PHP

Greetings! I've been experimenting with OpenFlash-Chart, and while some PHP graphs are showing up correctly, I encountered an error in my latest JavaScript code: Open Flash Chart IO ERROR Loading test data Error #2032 The URL I attempted to access: . ...

Ways to customize nav-pills for restricting the page count shown

Attempting to establish a pagination system with the implementation of nav-pills. The unique aspect is that these nav-pills are dynamically generated, resulting in instances where there may be just one or potentially over 100. Utilizing bootstrap 4 & ...

Utilizing the Flatpickr's onChange event to dynamically update the end date

I am utilizing two date pickers, start_time and end_time, both implemented with the flatpickr() function. When a date is selected for the start_time, I want the end_time to automatically update to match that value. To achieve this functionality, I am atte ...

AngularJS is receiving an array of null inputs

I have a form where data from my DB is displayed through WebApi. One of the controls will contain an array of values. There is a scenario where the user can edit and save it using the PUT function. Controller : $scope.Put= function () { $scope.i ...

The component "MeteorJS Collection" has not yet been initialized

superpack is an npm package that has been integrated using _wrapAsync. When attempting to insert into the collection UserSession, an error occurs indicating that the collection is undefined. server/helpers/b.js // Initialization var SUPERPACK = Meteor.re ...

Creating a new nested object in JavaScript using the keys of the current object

What is the most efficient method for creating a new object based on the keys of the current object? Each key in the original object should correspond to a specific element in the new object - for example, activityName1 should match the first element' ...

Determine whether the elements within an array are present on the webpage. If they are, display an alert. If not, reload the page

Initially, I had a userscript designed to search for a specific string within a webpage. If the script failed to locate the string, it would refresh the page after 4 seconds: var item = 'apple'; if(document.body.innerHTML.toString().indexOf(item ...

The JSON.stringify() method does not update the object that has been modified by an event

Below is the code snippet: //function triggered when columns are reordered dataTable.on('column-reorder', function (e, settings, details) { var userData = tableWidget.grid('userData'); console.log(userData); //userData object s ...

The disappearing act of the Show/Hide Button in Sencha Touch 2.3.1: what's the

I'm running into an issue with my sencha touch app. Here is the container I have defined: { xtype: 'container', text: 'SOMETHING', height: '15%', width: '15%', ...

How can I expand and collapse elements using Angular?

I'm looking to implement a collapsible feature. When the user clicks on the "Section Title", I want the corresponding information to collapse or expand. @Component({ selector: 'knowledge-base', template: ` <div *ngFor="let sect ...

"Step-by-step guide on using JavaScript to print a PDF file stored locally

As an illustration, I have a local PDF file with 6 pages. When using the window.print() function, only one page is displayed in print preview regardless of what is shown in the browser. Instead of just one page, all pages should be visible in print previ ...

Utilizing Angular Dependency Injection to Share Data Among Modules Through a Service

After reading about dependency injection in Angular, I decided to test it out. However, when trying to inject the module, I encountered an issue with passing values from one module to another and outputting them on the console. (Update: The issue has been ...

How do I collapse the sidebar in mobile and tablet view using Bootstrap 4?

I am trying to create a collapsible sidebar that expands on large screens such as lg, but collapses with a visible button for tablet and mobile views (md or smaller). How can I achieve this responsive behavior for my sidebar on mobile and tablet views? It ...

Issues with displaying HTML video content

Seeking assistance with a unique coding predicament. I've got an HTML file that showcases a JavaScript-powered clock, but now I'm looking to enhance it by incorporating a looped video beneath the time display. Oddly enough, when the clock feature ...

"Utilizing ng-select with ng-model: A Step-by-Step Guide

Currently, I am working on a code that involves using ng-repeat to loop through options. My goal is to utilize ng-select to choose a value based on a specific condition. However, according to the AngularJS documentation: ngSelected does not interact wit ...

Conflicting jQuery links arise when utilizing version 2.1.4 of jQuery

I have encountered a conflict with the jQuery link while using the LIMITLESS theme. Can someone please assist me in resolving this issue? <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.0/jquery.min.js"></script> The conflict is ...

What's the best way to set up server-side pagination for mui-datatable?

Is server-side pagination for mui-datatable implementation a complex task? Challenges: I am facing difficulties in capturing the user-selected value from the rowsPerPage options. When a user selects '15', how can I update these values within ...

Is Sending an Object to a Function in the Same Scope Inefficient?

Is there a noticeable delay when passing around an object within the same scope? Let's explore Option 1 and Option 2. In Option 1, we work directly with the object, while in Option 2 we follow better encapsulation practices. However, if we were to sti ...

Passing an array from PHP to the DataTables JavaScript library

I am attempting to pass a PHP array to the JS Datatable library for testing purposes. Instead of fetching data from a database, I have simplified my approach. Here is a basic representation of my PHP code: $data_fmt['data'][] = array("TEST"); e ...

Global Redirect Pro is a cutting-edge redirection tool that

Check out the code below which successfully edits a link to redirect users to a specific website based on their location. I'm interested in enhancing this code in two ways: $(window).load(function () { $.getJSON('http://api.wipmania.com/json ...