Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/sdk/android/manual/bug-reporting.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ The `Report` you receive is mutable. The most commonly used members:
- `setSeverity(IssueSeverity)` — one of `VeryLow`, `Medium`, `High`, `Critical`, `Blocker`.
- `addLabel(String)` / `addLabels(List<String>)` / `setLabels(List<String>)` / `clearLabels()` — dashboard labels.
- `getAttachments()` returns the current `List<Attachment>`; `createAndAddAttachment(name)` adds a new one (see [Attachments](/sdk/android/report-handler#attachments)).
- `setScreenshot(Bitmap)` / `setScreenshotAsync(Bitmap, Runnable)` — replace the screenshot. `setScreenshot` encodes and writes the image on the calling thread; `setScreenshotAsync` does it in the background and calls the `Runnable` once the screenshot is stored. See [Replacing the screenshot](#replacing-the-screenshot) for which one to use in `onCreated` and when to upload.

The same `Report` is what `ReportHandler.onBeforeReportCreated(...)` / `onAfterReportCreated(...)` hands you, so the same mutators apply there.

Expand Down Expand Up @@ -216,6 +217,44 @@ Bugsee.createReport { report ->
</TabItem>
</Tabs>

### Replacing the screenshot

`setScreenshot(Bitmap)` encodes the image and writes it to disk on the calling thread. For a screen-sized bitmap that takes over 100 ms, and `onCreated` runs on the main thread. Use `setScreenshotAsync(Bitmap, Runnable)` there, and upload the report from its callback:

- `setScreenshotAsync` returns before the screenshot is stored, and calls the callback once it is.
- A report uploaded before that can be sent without the new screenshot, so do not call `Bugsee.upload(report)` right after `setScreenshotAsync`.
- The callback runs on the thread that called `setScreenshotAsync` when that thread has a `Looper` (here, the main thread), otherwise on the main thread.
- The SDK reads the bitmap on a background thread after the call returns, and does not copy it, so do not recycle or change the bitmap until the callback runs. The report neither keeps nor recycles it: after the callback the bitmap is yours again.

<Tabs groupId="lang-android">
<TabItem value="java" label="Java">

```java
Bugsee.createReport(report -> {
if (report == null) {
return; // SDK not launched, or creation failed
}
Bitmap bitmap = renderCheckoutScreen(); // a Bitmap your app produces
report.setSummary("Checkout frozen");
report.setScreenshotAsync(bitmap, () -> Bugsee.upload(report));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 Low

Problem: bitmap is never defined in either example, and the text doesn't say where it comes from or who owns it. Unlike the example above, the snippet doesn't compile as written.

Impact: setScreenshotAsync encodes the bitmap after it returns. A reader who copies this and then recycles or reuses the bitmap right after the call (a common Android habit) races the encoder. The page doesn't warn about that.

Scenario: Bitmap bmp = renderScreen(); report.setScreenshotAsync(bmp, ...); bmp.recycle();. If the SDK reads the bitmap after the call returns, it hits a recycled bitmap.

Fix: Show where the bitmap comes from (e.g. Bitmap bitmap = captureScreen(); // your own bitmap). Add one line saying not to recycle or mutate it until the callback fires, if the SDK really reads it asynchronously. Please confirm against IssueReportScreenshot first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in e56e321. Both examples now produce the bitmap (renderCheckoutScreen(), "a Bitmap your app produces"). The section also says that the SDK reads the bitmap on a background thread after the call returns and does not copy it, so it must not be recycled or changed until the callback runs, and that the report neither keeps nor recycles it. I checked this against SDK v7.6.0: IssueReportScreenshot.setScreenshotAsync posts setScreenshotInternal(bitmap, …) to the aux thread, and the Report.setScreenshotAsync Javadoc says "The bitmap is fully encoded before it runs and is neither retained nor recycled by the report: the caller owns it."

});
```

</TabItem>
<TabItem value="kotlin" label="Kotlin">

```kotlin
Bugsee.createReport { report ->
report ?: return@createReport // SDK not launched, or creation failed
val bitmap = renderCheckoutScreen() // a Bitmap your app produces
report.summary = "Checkout frozen"
report.setScreenshotAsync(bitmap) { Bugsee.upload(report) }
}
```

</TabItem>
</Tabs>

## Severity values

`IssueSeverity` values: `VeryLow`, `Medium`, `High`, `Critical`, `Blocker`. See the [configuration reference — Enums](/sdk/android/configuration#enum-reference) for each value's meaning.
Loading