Memory leaks are occurring due to the texture from the video tag

Currently, I am working on creating a texture in THREE.js (r78) from a video tag and updating the texture 60 times per second by setting needsupdate=true in requestanimationframe. However, I am facing a problem where I notice memory leakage in the Chrome Task Manager. Specifically, in the task GPU Process under the column Memory (not GPU Memory), the value keeps increasing over time.

The video file I am using is an MP4 file encoded in H.264 with a frame rate of 60 fps. Below is the code I am working on. I thought of seeking advice on stackoverflow.com before raising a new issue on github.com for THREE.js.

    var video = document.createElement('video');
    video.src = 'test1.mp4';
    video.loop = true;
    video.load(); 
    video.play();

    video.onloadedmetadata = function() {
        initScene();
        animate();
    };

    var scene, camera, renderer, object;

    function initScene() {
        const W = 1280;
        const H = 720;
        camera = new THREE.PerspectiveCamera(30, W/H, 1, 5000);
        camera.position.z = 1000;
        object = makeVideoObject(video.videoWidth, video.videoHeight);
        scene = new THREE.Scene();
        scene.add(object);
        renderer = new THREE.WebGLRenderer({antialias:true, alpha:true});
        renderer.setSize(W, H);
        document.body.appendChild(renderer.domElement);
    }

    function animate() {
        object.material.map.needsUpdate = true;
        renderer.render(scene, camera);
        requestAnimationFrame(animate);
    }

    function makeVideoObject(w, h) {
        var texture = new THREE.Texture(video);
        texture.minFilter = THREE.LinearFilter;
        texture.magFilter = THREE.LinearFilter;
        var material = new THREE.MeshBasicMaterial({ map:texture });
        var geometry = new THREE.PlaneGeometry(w, h, 1, 1);
        return new THREE.Mesh(geometry, material);
    }

In my attempts to resolve the memory leakage issue, I also experimented with creating the texture from a canvas tag and updating its context by calling context.drawImage(video, 0, 0) before setting needsupdate=true. Unfortunately, this approach also led to memory leakage.

EDIT After facing this issue, I have submitted it as a bug. For more information, check out https://github.com/mrdoob/three.js/issues/9440

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

What is the best way to transfer a variable from PHP to JavaScript as the actual variable itself, rather than as a string?

I am transferring data from PHP to JavaScript using AJAX. I apply json_encode before sending the data. Here is an example: $data = [ [ "path" => "/TestMenu1", "component" => 'test1', "children" => [[ ...

What is the process for importing JSON from an NPM package in Angular version 15?

I've been dealing with a local package that contains a json file, and my current challenge is to load this json file into the Angular 15 app.component.ts. To bring the json file package into my Angular project, I followed this installation process: n ...

Javascript splice method mistakenly eliminating the incorrect elements

I have an array of objects like the one below: [{"name":"Rain"},{"name":"Storm"},{"name":"Forest"}] These objects are indexed as follows: [0, 1, 2]. I'm attempting to delete an item at a specific position using this code: $scope.selectedSound ...

Issue with Accessing Subdomain Cookies on Express Backend Using CORS and Cookie-Parser

I am currently tackling a challenge in my MERN (MongoDB, Express, React, Node.js) application related to receiving cookies from subdomains in my Express backend. Despite implementing CORS and cookie handling successfully for a simple localhost origin, I am ...

Should we consider packaging the npm dependencies code along with our code as a best practice?

What is the best way to handle npm dependencies in our code bundle? If it's preferable to include the npm dependency code in our bundle, does it make sense to add it as a separate module or package? If not, how can I prevent bundling my dependencie ...

Cease making commitments or declarations

I am currently working on validating an image using an API. I have implemented promises and want the execution to stop and call a function if the API check fails. Here is my code: The function for calling the promises: checkPhotos(options,formData, "fr ...

Dealing with AngularJS: Overcoming Lexer Errors When Passing Email Addresses for Regex Validation in Functions

Trying to pass an email address to an AngularJS function has been my recent challenge. Below is a snippet of the code I've been working on. <script> //For simplicity, descriptions for the module and service have been omitted this.sendEmail = f ...

Encountered issue while converting half of the string array to JSON using JavaScript

I encountered an issue with the code below while trying to convert an array into JSON. Here is my code: <html> <head> </head> <body style="text-align:center;" id="body"> <p id="GFG_UP1" style="font-size: 16px;"> </p ...

The insertion was unsuccessful: Technique used in Meteor 1.3 and React

I am looking to add some simple text to the MongoDB using React. However, when I submit the form, the following error message is displayed in the console: insert failed: Method '/resolutions/insert' not found My setup includes autopublish and i ...

Ways to determine if the backbone.js model has been emptied

I often find myself wondering how to determine if a model has been cleared or is empty. For example, if I set the model with: model.set({name:'this is a test', id:1}); and then clear it with: model.clear(); ...

AngularJS users are experiencing issues with the "See More" feature not functioning as expected

One of my tasks involves dealing with a block of text that needs to be truncated using ellipsis. To achieve this, I am utilizing jquery dotdotdot. For more information on dotdotdot, please refer to the documentation. I have created a straightforward dire ...

Creating captchas seems like a mistake in reasoning to me

I am encountering an issue with my code. I created a basic newbie-level captcha using Javascript. Below is the code snippet: <!DOCTYPE html> <html> <head> <style> </style> </head> <body> <h1>T ...

Populate a JSON table in React with checkboxes and automatically mark them based on the JSON data

I'm currently working on creating a React table using JSON data like this: [ { "Id_side": 123, "Name_side": "R4", "Name_cycle": "C1" }, { "Id_side": 345, "Name_side": "M1", "Name_cycle": "C2" ...

React does not automatically re-render components created with the built-in function

I'm facing some confusion with the behavior in my code: I've created a component that should function as a menu using MaterialUI. The idea is that when a button in the menu is clicked, it becomes "active" and visually reflects this change by set ...

Blending Angular5 and AngularJS in Polymer

We are considering launching two new projects - one using Angular 5 and the other utilizing Polymer. The second project is intended to serve as a component library for reuse in not only the Angular 5 project but also in other AngularJS projects. After res ...

Is there a way to store the JWT response header retrieved with fetch?

I am currently utilizing React and employing fetch to send a request to the server: fetch("http://localhost:8001/api/login", { method: 'post', headers: { "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" }, ...

npm causing problems with babel-cli

While working on building a section of my library with Babel, I've encountered some issues when running Babel commands through npm. In my npm script named "build," the following commands are executed: { "prebuild": "rm -rf && mkdir dist", ...

"AngularJS fails to pass the value of a checkbox within ng-repeat and

I have already asked this question, but the previous solutions did not resolve my issue. I am attempting to pass the value of a checkbox to a controller in AngularJS, but I keep getting an 'undefined' message. I am new to AngularJS. Here is the ...

Guide: Linking RCTCameraRoll to Android

I am currently attempting to utilize the CameraRoll library, however, I have encountered an obstacle. The documentation does not provide instructions on linking it for Android. It only offers guidance on how to link it for iOS. While it does mention that ...

Which type of element does Youtube utilize for the videos on its own domain - <iframe> or <video>?

Do they have a different method for incorporating their videos? My goal is to utilize the playbackRate property on a non-embedded YouTube video for a Chrome extension. ...