emscripten-core / emscripten-core/emscripten

Memory leak in webgl. canvases are never garbage collected. WebGLUniformLocations

Aperta
#13,697 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
wontfix
Lingua principale
C++
Stelle
27.6k
Fork
3.6k
Merge medio
1g 14h
PR unite (30g)
125

Descrizione

I was chasing a problem were a simple test would allow my webgl canvas once lost, to become restored once the garbage collector ran, but in the real product, it never happened. This is what I learned after doing some memory analysis:

In the function populateUniformTable:
https://github.com/emscripten-core/emscripten/blob/bdf9e073b58892017919991a993568a9de10e557/src/library_webgl.js#L1123

the WebGLUniformLocation objects are stored in the GL.uniforms array which does not go away when a context is destroyed.
This has the effect of keeping a link to the context so it never gets garbage collected.

What should be happening is in glDeleteProgram:
https://github.com/emscripten-core/emscripten/blob/bdf9e073b58892017919991a993568a9de10e557/src/library_webgl.js#L3097

the references to the WebGLUniformLocation should be removed from the GL.uniforms array.

Either that, or all the references to GL.uniforms should somehow find their way to the program and they should be stored in the ptable object here:
https://github.com/emscripten-core/emscripten/blob/bdf9e073b58892017919991a993568a9de10e557/src/library_webgl.js#L1128

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in src/library_webgl.js, in populateUniformTable e glDeleteProgram, usando le revisioni collegate come contesto. Traccia il modo in cui gli oggetti WebGLUniformLocation entrano in GL.uniforms e il modo in cui la distruzione dei programmi li gestisce. Il lavoro è completato quando i contesti distrutti non rimangono più raggiungibili tramite quei riferimenti; convalidalo con una riproduzione mirata o un'analisi della memoria come descritto nel report.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript
Ambito
computer-graphics, performance
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.