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

Capture pixel screenshots implementation on iOS #99

Merged
merged 9 commits into from
Nov 6, 2024

Conversation

Reflejo
Copy link
Contributor

@Reflejo Reflejo commented Nov 5, 2024

Example of a capture

❯ ls -lah a.jpg
-rw-r--r--@ 1 martin  staff    78K Nov  4 16:13 a.jpg

Takes about 500ms running on device

a

@Reflejo Reflejo requested a review from Augustyniak November 5, 2024 00:13
Copy link
Contributor

@Augustyniak Augustyniak left a comment

Choose a reason for hiding this comment

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

Added assertions and a comment, looks good. May be worth adding information about why it's safe to render on a background thread (you mentioned that it was tricky to find out whether it's OK to do it on a background thread or not)

// To handle cases where no window is available, an assertion is included here.
// TODO: Add a log to inform the Rust layer if the screenshot log emission fails, allowing it
// to proceed to the next screenshot (if any).
assertionFailure("no window to take screenshot of")
Copy link
Contributor Author

@Reflejo Reflejo Nov 5, 2024

Choose a reason for hiding this comment

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

If that’s the case might be better to send an empty data object back for now, wdyt? @Augustyniak

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, makes sense - so if we send a screenshot log without screen field set then you will handle it somehow on the frontend layer?

Copy link
Contributor

Choose a reason for hiding this comment

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

or do you want me to somehow annotated such log with an extra attribute?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll handle in the fe

Copy link
Contributor

Choose a reason for hiding this comment

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

cool, let me make a change in your PR in here

@Reflejo Reflejo force-pushed the capture-pixel-screenshots-implementation-on-ios branch from e43ff93 to 29d6bcc Compare November 5, 2024 17:48
@Augustyniak Augustyniak merged commit 6778441 into main Nov 6, 2024
14 checks passed
@Augustyniak Augustyniak deleted the capture-pixel-screenshots-implementation-on-ios branch November 6, 2024 14:10
@github-actions github-actions bot locked and limited conversation to collaborators Nov 6, 2024
let layer = window.layer
let bounds = UIScreen.main.bounds.size

self.queue.async { [weak self] in
Copy link
Contributor

Choose a reason for hiding this comment

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

@Reflejo for my android-side understanding: would these two operations happen on separate threads? are any of these new worker threads or do we re-use existing ones?

Copy link
Contributor

Choose a reason for hiding this comment

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

similarly, those these threads get spawned even when the runtime flag session_replay.screenshots.enabled is off?

Copy link
Contributor Author

@Reflejo Reflejo Nov 12, 2024

Choose a reason for hiding this comment

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

Queues do not map 1:1 to threads, we actually use a default queue for the target here meaning this won't create an additional thread.

The lines that are under the DispatchQueue.main.async but above self.queue.async will be dispatched to the main thread (basically just to access the layer object) then the self.queue.async closure runs that in our serial queue mentioned before

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm more confused than before? then what's the diff between queue and thread? what does default mean?

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

Successfully merging this pull request may close these issues.

3 participants