-
Notifications
You must be signed in to change notification settings - Fork 156
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
Window Resize Handling #107
Comments
Your saying it does not resume capturing? The reason the library stops and restarts is mostly because its easier to do this. |
Also, removing that line of code will cause your stomp all over memory if the new area to capture is larger than the previous one since the buffers are pre allocated in the init function and not in the process functions |
screen_capture_lite/src/ScreenCapture.cpp Line 76 in 49873d5
This is the main loop. As long as expected errors keep recurring, the library will restart itself automatically. |
Technically it does resume, but restarts immediately again. So for the end-user it does not resume capturing. Because the variable named window (and it's parameter size) is not be changed before restarting. It will keep restarting every loop, because window.size.x and window.size.y will rarely ever be the same value again. |
Okay so the library is working. |
I dont think it will resume capturing the window at any point in time. At least it did not at any point in time for me. |
When an expected error occurs the library will rebuild itself calling init, getting a new list of windows/monitors to capture. Just following the code from what I linked above. |
I think you will need to debug a little more unfortunately So add some debug statements around the code base to see where the code is failing to restart. You would be the first person to report an error like this so its not likely this is whats happening |
These are these are the areas where these events are handled screen_capture_lite/src/ScreenCapture.cpp Line 85 in 49873d5
AND
So if its not resuming this will be easy to spot |
i dont really know how to explain it better then this. |
just to be sure: this is on ios / osx implementation, i dont know about the windows or linux implementation. |
Ok, so your saying when the thread aborts, is the callback to get windows called again?
So im gonna layout what I think is the the callstack
Is called and DUPL_RETURN_ERROR_EXPECTED is returned The function above is this one
This function has the loop for the window capturing and it keeps going On this line
data->CommonData_.ExpectedErrorEvent = true; Then a few lines down there is a return true statement. Does this seem correct so far? So, the thread is created here for that function above screen_capture_lite/src/ThreadManager.cpp Line 40 in 49873d5
The line above is called from the MainScreenCaptureManager screen_capture_lite/src/ScreenCapture.cpp Line 83 in 49873d5
As you can see, when So, the window variable you referring to will be thrown out because this line will recreated everything screen_capture_lite/src/ScreenCapture.cpp Line 93 in 49873d5
I think we need more information. The line you are referring to will recreate everything If you can verify that when the thread restarts, that the callback to get the windows to watch is called, that would be helpful because it means that code is working fine and its something else. Can you put a stop on the window size not matching to see how much it is off by? Is it off by 1, or is it 0. I think that's helpful too, I wana help, but from everything i am seeing, its likely something other than the library. A way to figure this out would be to run the example file and see how that behaves to eliminate any other factors. |
What I think we will find is that you have a buffer overrun somewhere that is overwriting the memory. |
Another possibility is that the size of the image coming out of
has changed in some release of ios. Maybe it not includes padding or something else? The get windows function here https://github.com/smasherprog/screen_capture_lite/blob/master/src/ios/GetWindows.cpp Might have some strangeness going on too. Or some scaling issue might be occurring. Unfortunately, I dont use ios and developing on it is cumbersome so it takes me a long time to around to debugging ios. |
I can Agree to everything you wrote above except 1 thing i assume is wrong / different in my case:
It will use the old Window variable given by the user at the first/initial creation of the thread. It will not use the updated window size. It might actually also be that because using a c interface the window variable content is a copy of the original window variable and not a pointer to the internal variable. |
After long consideration of my problem and your description how it should work i am pretty sure about the cause of the problem. in c++ you return a list of windows to the user, which afaik is actually a pointer to the variable. The user returns the list of windows he wants to capture, which usually would be the original variable you sent the user in the first place. Using the C-Interface or from C# i cant return the same variable, so it's a copy of the variables content. I actually wondered why you would use the whole window variable to define which windows to capture. Thats the reason my window variable is static and does not get udpated with the new window size values. |
So this is happening when serializing from c to c#? |
Since the handle is a size_t, you can use IntPtr for the c# representation. |
I could be mistaken, but i think there is no way of accessing the contents of a intptr without copying the contents from the intptr using marshal. also i wouldnt know how to manipulate and return a pointer at all from c#. In my opinion it's a very bad idea to assume that the user returns the same pointer, as the library returned from a function. Especially when it's interfaced with other languages that might not even know about pointers. I'd rather just use a api that takes window/screen id's (if that is fix and consitent over all plattforms) and possibly a rect for a specific part of a screen, to define which parts to record. |
I just merged a large PR into master which includes part of the working c# implementation. So, that should help out with examples on how to move forward. |
Hi, i have been trying to figure out why screen recording stops when windows are resized. I figured out that, while it restarts the thread when capturing is interrupted by window resizing, it will allways abort. The reason is that it requires the stored window size to be the same as the image received from the desktop. The window is the one first defined when starting capturing, which will cause the thread to be aborted every loop. On OSX this is caused by:
line 30 in src/ios/CGFrameProcessor.cpp
commenting that lines seem to fix it and not cause any problems, but i dont know about the other plattforms.
Now the question is how should it be handled? Send a callback trough the API to give the possibility to react to the thread being restarted. Or should it try to keep recording the same window. In that case do we need to inform the user about the image size change, or do we assume he gets the image and can handle it on his own.
The text was updated successfully, but these errors were encountered: