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

[andr][sdk] Screenshot taking capabilities #122

Merged
merged 43 commits into from
Nov 15, 2024
Merged

Conversation

murki
Copy link
Contributor

@murki murki commented Nov 10, 2024

Android screenshotting support. Uses PixelCopy API. Fixes BIT-4040

Example sessions:

Screenshot 2024-11-10 at 3 24 16 PM

@murki murki changed the title Murki/andr screenshot [andr][sdk][wip] Screenshot taking capabilities Nov 10, 2024
Base automatically changed from murki/replay-simpl-refactor to main November 12, 2024 14:53
@murki murki marked this pull request as ready for review November 14, 2024 22:49
@murki murki requested a review from Augustyniak November 14, 2024 22:50
@murki murki changed the title [andr][sdk][wip] Screenshot taking capabilities [andr][sdk] Screenshot taking capabilities Nov 14, 2024
import java.io.ByteArrayOutputStream
import java.util.concurrent.ExecutorService

internal class ScreenshotCaptureEngine(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

^ this is where all the main logic lives

@murki murki requested a review from Reflejo November 14, 2024 22:56

private fun compressScreenshot(resultBitmap: Bitmap): ByteArray {
return ByteArrayOutputStream().use { outStream ->
resultBitmap.compress(Bitmap.CompressFormat.JPEG, 10, outStream)
Copy link
Contributor

Choose a reason for hiding this comment

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

have we tried making this 0?

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is using full size with device's pixel density I'd also consider resizing it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can see the result images in the linked sessions, the metadata also contains the used bytes and time spent on each operation

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.

Glue code looks fine

* Forwards an error message internally to the SDK
*/
fun logErrorInternal(message: String, e: Throwable? = null, fields: Map<String, String>? = null)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}

fun logDebugInternal(message: String, fields: Map<String, String>? = null)

/**
* Forwards an error message internally to the SDK
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Forwards an error message internally to the SDK
* Forwards an error message internally to the SDK.

fun logVerboseInternal(message: String, fields: Map<String, String>? = null)

/**
* Forwards a debug message internally to the SDK
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Forwards a debug message internally to the SDK
* Forwards a debug message internally to the SDK.


interface IInternalLogger {
/**
* Forwards a verbose message internally to the SDK
Copy link
Contributor

Choose a reason for hiding this comment

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

Nits in this file. Feel free to ignore.

Suggested change
* Forwards a verbose message internally to the SDK
* Forwards a verbose message internally to the SDK.

}
logger.logErrorInternal(message, e)
// Log empty screenshot on unblock the rust engine caller
logger.onScreenshotCaptured(ByteArray(0), metrics.data())
Copy link
Contributor

Choose a reason for hiding this comment

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

just to make sure that it's intended: do we want to log this on old Android versions that we do not support screenshotting for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up deciding to do it and track it in internal sdk logs in case I need to surface it

@murki murki enabled auto-merge (squash) November 15, 2024 21:54
@murki murki merged commit f6edcc1 into main Nov 15, 2024
15 checks passed
@murki murki deleted the murki/andr-screenshot branch November 15, 2024 23:31
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2024
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