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

Are there any unused created entities? #21

Open
safocl opened this issue Oct 23, 2020 · 7 comments
Open

Are there any unused created entities? #21

safocl opened this issue Oct 23, 2020 · 7 comments

Comments

@safocl
Copy link

safocl commented Oct 23, 2020

from line https://github.com/jaelpark/chamferwm/blob/master/src/compositor.cpp#L1465 to line https://github.com/jaelpark/chamferwm/blob/master/src/compositor.cpp#L1469 -- are the entities used?
xcb_shm_get_image_reply_t * is created but then only released without use.
Do we have to create these entities?

There are several such situations in your code.

@jaelpark
Copy link
Owner

I don't think lines 1465 to 1469 are in fact unnecessary, even though it might appear so. While the call to xcb_shm_get_image for example looks out of place, internally it (I presume) updates or syncs the buffers for external access. Earlier, I did try would it work without it, or if I moved it to somewhere else and called it maybe once, but the testing showed that it would only result in black buffers. I'm not aware of better usage when dealing with SHM though. What are the other occurrences where it would seem (or is definitely the case) some portion of code is not needed?

@safocl
Copy link
Author

safocl commented Nov 10, 2020

What are the other occurrences where it would seem (or is definitely the case) some portion of code is not needed?

in that file the lines 1485-1489.

@safocl
Copy link
Author

safocl commented Nov 10, 2020

I don't think lines 1465 to 1469 are in fact unnecessary, even though it might appear so. While the call to xcb_shm_get_image for example looks out of place, internally it (I presume) updates or syncs the buffers for external access. Earlier, I did try would it work without it, or if I moved it to somewhere else and called it maybe once, but the testing showed that it would only result in black buffers. I'm not aware of better usage when dealing with SHM though.

ok, but why creating pointer xcb_shm_get_image_reply_t *pimageReply?

@jaelpark
Copy link
Owner

In some cases the image depth is given by pimageReply, although not needed everywhere. However, elsewhere we're just getting the reply and then discarding it immediately after by freeing the memory. This just gave me an idea that I could try xcb_discard_reply instead of calling xcb_shm_get_image_reply. The problem might be that xcb_discard_reply is non-blocking, and the buffers may not yet be available for copying by the time it returns, so it might fail. But I will test it for sure, and if everything looks normal, I can make the changes.

@jaelpark jaelpark reopened this Nov 10, 2020
@jaelpark
Copy link
Owner

Nope, it didn't work. While the window contents are visible, the frames are no longer synchronized. In the current design, xcb_shm_get_image_reply is needed to wait for the internal update to finish, and the returned pointer is needed to free the memory. I'll leave this open again for some time if there will be better ideas how to handle it.

@safocl
Copy link
Author

safocl commented Nov 10, 2020

I just think that *_reply is for data access only -- it does nothing about the internal Xorg structure.

@jaelpark
Copy link
Owner

It doesn't, but it allows one to wait for the internals to be ready for copying. If the next step i.e. access to the shared memory buffers is done without it, it seems to result in glitching and dropped frames.

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