gre / gre/gl-react

Deallocate textures from memory

Aperta
#246 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
3k
Fork
160
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

First of all, thanks for the great work done on this library. It's an amazing tool.

### _feature request / bug report_
Actually I'm not really sure if the behavior I'm seeing is expected for the library, but it's not the one I expected, so I don't know whether it's a bug report or a feature request.

#### library version

```
┬── gl-react@4.0.1
└─┬ gl-react-native@4.0.1
└── gl-react-expo@4.0.1
```

#### Expected behavior
After a texture is changed in the shader, the memory allocated for it will be deallocated, resulting in a smaller memory footprint, and thus avoiding memory related crashs (even if this means that a previously used texture will have to be reallocated for posterior use).

#### Actual behavior
Each time I change a texture in my component, the memory usage increases, only returning when the surface is finally unmounted (meaning the screen was closed).

#### Steps to reproduce the behavior
Just create a shader that takes a Sampler2D uniform and change it with something like a carrousel.

An example of the current behavior is in the profiling below:

![memory_allocation](https://user-images.githubusercontent.com/62310432/82695334-42721e00-9c3b-11ea-88f3-505844b2e662.png)

The ramp A represents the initial rendering of the base image (the image that will be edited). This one is fixed.

Ramp B represent a succession of different group 1 textures being applied (Each application changes the old texture for the new one, resulting in only one group 1 texture being applied at any given time). After that, I left it static for a while.

Another batch of successive group 2 textures application came just after (one group 1 and one group 2 textures would be applied at any given time), resulting in ramp C.

At point D, the screen was closed.

What I was hoping is that a max of 3 allocations was sustained (one base texture, one group 1 texture and one group 2 texture). Is there any way that I can achieve this behavior? Even if I have to manually deallocate the texture.

Thanks in advance.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia tracciando il ciclo di vita delle texture Sampler2D nelle superfici gl-react e gl-react-native, concentrandoti sulla sostituzione delle texture e sullo smontaggio delle superfici. Riproduci il caso del carosello descritto nel report e analizza l’utilizzo della memoria; il lavoro è completato quando le texture sostituite vengono rilasciate, in modo che rimangano allocate solo le texture attualmente utilizzate.

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

Valutazione

Stack tecnologico
react, react-native, typescript
Ambito
computer-graphics, mobile-dev
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.