gre / react-native-view-shot

Snapshot a React Native view and save it to an image
https://github.com/gre/react-native-view-shot-example
MIT License
2.64k stars 343 forks source link

Advice needed - what’s the most efficient way of getting pixel data into a buffer #446

Closed tomyates closed 1 year ago

tomyates commented 1 year ago

I’m currently doing something which I admit is pretty hacky but I’d like to know how to improve it.

I have an iOS app, and I'm using a 3D engine (Babylon) to render a scene. One the elements of the scene is a sprite that gets it's texture from a video elsewhere in RN.

15 times a second I’m taking a shot of a webrtc video component and saving the result as a png tmp file. In Babylon, I’m loading that in as texture by reading the tmp file 15 times and second.

This works ok, however, it feels really inefficient and a waste of hdd read and writes. I've tried using base64 string data instead - but this is far slower, as it's coming over the bridge.

Is there a better solution that doesn't use tmp files, perhaps using RAW pixel data?

Thanks!

gre commented 1 year ago

i'm not really sure how this question relates to this library. i'm afriad you may need to ask on other website, like stackoverflow.