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

Refactor: introduce FrameGuard, ScreenCapturer, and Logical/EmbeddedRegion #71

Closed
wants to merge 1 commit into from

Conversation

AndreasBackx
Copy link
Member

@AndreasBackx AndreasBackx commented Oct 25, 2023

@AndreasBackx AndreasBackx changed the title Add freeze Refactor: always screencopy full output, new FrameGuard and ScreenCapturer Oct 25, 2023
@AndreasBackx AndreasBackx force-pushed the pr71 branch 2 times, most recently from 3368d06 to ac951cb Compare October 25, 2023 02:19
@AndreasBackx AndreasBackx force-pushed the pr71 branch 2 times, most recently from 4077a85 to becea47 Compare October 25, 2023 21:42
@Shinyzenith
Copy link
Member

Another question that I had, can we not screencopy all outputs when freeze is not asked for? Freeze can be an opt-in feature via a flag.

This is for the people who'd rather buy performance over freeze.

Also do we still scrcpy all outupts even when only one output is specifically asked for?

@Shinyzenith
Copy link
Member

This would also be a good opportunity to introduce a Changelog for libwayshot for downstream clients as we are making breaking changes to the API very often.

libwayshot/src/dispatch.rs Show resolved Hide resolved
libwayshot/src/dispatch.rs Show resolved Hide resolved
libwayshot/src/dispatch.rs Show resolved Hide resolved
frame.buffer_done.store(true, Ordering::SeqCst);
}
_ => unreachable!(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once the flag event removal is reverted, this needs to be changed back to unreachable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'd want to avoid however, is when there is a newer version of screencopy with a new event, that we'd reach this leading to an error. If the event enum is exhaustive, we can remove the _ => {} and be sure this won't happen anyhow. If it's not, I'd want to keep _ => {} and not _ => unreachable!() as it might lead to errors in the future, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand where you're coming from. I believe we request the exact version of screencopy we want from the queuehandle anyways, when we update the version of scrcpy, the compiler should warn us of an unhandled cases right as it's an exhaustive enum? So maybe we can just expand the handler with some polyfill (eg: //TODO: handle this later/ignored event) for the cases we don't currently handle?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we request the exact version of screencopy we want from the queuehandle anyways

Now that you mention this, we need to update the code afaik to say version X or higher as I think right now if a new version is introduced, we won't support a compositor that reports a higher version even though it should also support the older version. 🤔 Though unrelated to this PR.

when we update the version of scrcpy, the compiler should warn us of an unhandled cases right as it's an exhaustive enum?

It might warn us (though don't think so because we have _ => {}), a newer version will still hit _ => unreachable!(). We simply cannot guarantee this is unreachable with a non exhaustive enum.

libwayshot/src/region.rs Outdated Show resolved Hide resolved
libwayshot/src/region.rs Outdated Show resolved Hide resolved
libwayshot/src/region.rs Outdated Show resolved Hide resolved
libwayshot/src/lib.rs Show resolved Hide resolved
Copy link
Member Author

@AndreasBackx AndreasBackx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to write up the PR information, it's been hectic these last few days/weeks. But thanks for the reviews in the meantime everyone!

libwayshot/src/dispatch.rs Show resolved Hide resolved
libwayshot/src/dispatch.rs Show resolved Hide resolved
frame.buffer_done.store(true, Ordering::SeqCst);
}
_ => unreachable!(),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I'd want to avoid however, is when there is a newer version of screencopy with a new event, that we'd reach this leading to an error. If the event enum is exhaustive, we can remove the _ => {} and be sure this won't happen anyhow. If it's not, I'd want to keep _ => {} and not _ => unreachable!() as it might lead to errors in the future, no?

libwayshot/src/image_util.rs Outdated Show resolved Hide resolved
libwayshot/src/lib.rs Show resolved Hide resolved
libwayshot/src/region.rs Outdated Show resolved Hide resolved
libwayshot/src/region.rs Outdated Show resolved Hide resolved
libwayshot/src/region.rs Outdated Show resolved Hide resolved
libwayshot/src/region.rs Outdated Show resolved Hide resolved
@Shinyzenith
Copy link
Member

Still need to write up the PR information, it's been hectic these last few days/weeks. But thanks for the reviews in the meantime everyone!

Take your time! thanks for your contributions, there's no rush. My apologies if I reviewed something incorrectly without proper understanding, I'll give it all another go after the info is up so I can properly guage the change surface.

@AndreasBackx AndreasBackx changed the title Refactor: always screencopy full output, new FrameGuard and ScreenCapturer Refactor: introduce FrameGuard, ScreenCapturer, and Logical/EmbeddedRegion Oct 31, 2023
@AndreasBackx AndreasBackx force-pushed the pr71 branch 5 times, most recently from 1a3e051 to b5a797e Compare October 31, 2023 01:14
@AndreasBackx AndreasBackx force-pushed the pr71 branch 2 times, most recently from 790bf8b to 2649b28 Compare November 9, 2023 22:04
@Shinyzenith
Copy link
Member

I think this PR is ready to be merged. Any comments @Decodetalkers? I'll start landing this stack entirely.

}

fn create_frame_copy(
pub fn capture_frame_copies(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this function is public ,so I think add docs is needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might be able to keep this private. I forgot if it was used, I might've forgot to undo this.

@Decodetalkers
Copy link
Collaborator

I think this PR is ready to be merged. Any comments @Decodetalkers? I'll start landing this stack entirely.

I also think this pr is ok, maybe document can added later

@Shinyzenith
Copy link
Member

I will be closing down the rest of the stack since the top of the stack has been merged with all the changes included 😄

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

Successfully merging this pull request may close these issues.

3 participants