Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic unity exsample #112

Open
ludos1978 opened this issue Aug 25, 2021 · 10 comments
Open

basic unity exsample #112

ludos1978 opened this issue Aug 25, 2021 · 10 comments

Comments

@ludos1978
Copy link
Contributor

Hi, i've added a basic unity example in the fork https://github.com/ludos1978/screen_capture_lite . Also there is a extendedSample in scenes and in Scripts that are wip and not needed in the basic sample.

the dll or dylib needs to be added to the Example_Unity/UnityProject/Assets/Plugins folder so it works.

onMouseChanged and onNewFrame work as far as i can tell. But the onFrameChanged generates broken images. I assume thats an internal problem, also it has happened that i received a wrong size of buffer for the image size.

To cleanup i had to add a function. Unity closes the application fast and afaik only awaits the OnApplicationQuit function call. Garbage collection is not fast enougth i think. I do encounter problems when play/stopping the project in unity from time to time, but it's really hard to tell where these unity crashes come from. I assume it's because it may still execute the callback even if i set TerminateThreadsEvent true and Paused false in rare cases.

@smasherprog
Copy link
Owner

i see your not using dispose on the resources, this is likely whats causing the issues you are getting when trying to stop capturing.
Mac has issues with inframechanged unfortuantly.
I havent bug into that issue, but it looks like the images returned each frame from ios are slightly different from the previous. Maybe I need to add some jitter detection or dig into it more.

Dispose will block and wait until the capturing has completely stopped and all resources have been successfully cleaned up.

@smasherprog
Copy link
Owner

I think the stop function isnt necessary,. Give disposing the resources a shot and see if that fixes it.

@ludos1978
Copy link
Contributor Author

dispose seems to work equally well. i have checked in that change already, however i did not remove the stop functions from c & c# codes.

the problems with the images onFrameChanged appear to be a wrong width/height. width should be 2 - 3 times bigger. in most images.

@smasherprog
Copy link
Owner

smasherprog commented Aug 26, 2021

Maybe its time for me to start up the good ol' mac thats collecting dust....

Ill see checking the mac stuff this weekend and look over the branch that you made.

Thanks for all the hard work. I saw that you were implementing your own c# library.

@smasherprog
Copy link
Owner

smasherprog commented Sep 6, 2021

Fired up the good'ol mac, updated everything and everything seemed to work fine for my setup which is a simple, single monitor setup.
I did try different scaling of my monitor and everything still seemed to work ok.
I dont doubt that there are issues, but my mac debugging ability is limited so I cant see what needs to be fixed :(
If you want to take a stab at fixing it, that would be awesome.

@smasherprog
Copy link
Owner

This was also not using unity. I dont use that either. I just did the simple demo of capturing monitors/windows

@smasherprog
Copy link
Owner

Also, on the topic of unity plugin. I was going through merging your code into the repo and was reviewing the code.

Since I dont use unity. The resource cleanup of
OnApplicationQuit
vs OnDestroy

Should OnDestory be used instead of OnApplicationQuit?

I am asking this because I generally dont know. I did google this and it seems to indicate that OnDestroy should be used. Is this correct?

@ludos1978
Copy link
Contributor Author

ludos1978 commented Sep 7, 2021 via email

@ludos1978
Copy link
Contributor Author

I just wanted to remind you that the samples in the repository https://github.com/ludos1978/screen_capture_lite should be working. if you wanna import them. you could leave out the ExtendedSample in Scripts and Sample as well as the built lib in Plugins and all the meta files with the same name as the files. but othervise it's about as small it gets.

@smasherprog
Copy link
Owner

Yeah sorry ive been busy.
I did look at the example and was trying to use it locally. Ill get something up soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants