keijiro / asynccapturetest Goto Github PK
View Code? Open in Web Editor NEWNon-blocking screen capture example with asynchronous GPU readback
Non-blocking screen capture example with asynchronous GPU readback
Hi!
Is it possible to make the SaveBitmap() method async?
I need to encode the Color32/Byte array to JPG in another thread so that it doesn't create any micro-lag on the main thread.
Thanks a lot in advance!
Hi there,
i have tried this project with different Unity Versions (2019.4.14f1 , 2020.3.25f1 and 2021.2.8f1) and have a problem. Hope someone can help me.
The application crashes after about 10 minutes.
I have also tried the same test while deactivating this line "System.IO.File.WriteAllBytes("test.png", encoded.ToArray());"
It still crashed in editor or standalone mode after running for about 10 minutes.
I have tried the tool "Log Viewer" to see in Standalone Mode if there is a Memory Leak. Everything looked normal. Maybe there are better tools to analyse?
Is this a Unity Bug?
Is it maybe better to replace this "yield return new WaitForSeconds(1);" with something like a request done to have maximum speed?
I would like to create a video stream application which is stable and fast. Is it wise to use AsyncGPUReadback or is there a better and more stable option?
Thank you, hope you have some advises!
Hi! This is awesome, and I thank you for providing such a succinct and clear example. I've been playing with it a bit for the last day or two and have it running great when cloned directly and on a minimal project -- but when running the exact same code on our game's camera I end up with unexpected resolution / pixel counts.
The code here is completely unchanged from your repo, and admittedly it works fine when run in a project by itself. When run in our main project, the exact same code on the exact same computer & unity version, ends up producing the error.
Here's a link that contains screenshots:
https://imgur.com/a/aKxc3Sh
Screenshots show:
I'm guessing that there is something dumb and/or obvious that I'm just completely missing here, but after 2+ hours playing with it I'm at a loss as to what/why this would occur.
Does anything jump out at you as being wrong or incompatible?
FWIW, I've also tried using a separate camera -- both active, and inactive while manually calling Render(), both of which produced similar unexpected resolution/array size results too.
Apologies in advance for what is probably a stupid/obvious mistake on my part!!! =D
My Setup:
buffer.Length=5610480 || buffer.ToArray().Length=5610480 || Screen: 2410x1164 || Camera: 2410x1164 || scaledCamera: 2410x1164 || Args: 2410x1164
This doesn't work on Android,
req.hasError is always true. Any ideas why or if it's fixable?
Hi Keijiro, thank you so much for the demo code, it is very informative.
I have been playing with asyncGPUReadback and it is very useful however I am wondering if it supports HDR. I have tried using GetData with and I tried putting RenderTexture using both ARGBHalf a.k.a. DefaultHDR and ARGBFloat. Neither work, I just get an empty array, i.e. array of zeroes. And quite peculiar if I use ARGBHalf I get exactly half the pixels I should from GetData method, I guess it just combines two ARGBHalf into one ARGBFloat.
the Error said : Assets\AsyncCapture.cs(16,13): error CS0103: The name 'ScreenCapture' does not exist in the current context
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.