Skip to content

docs(android): upload a created report from setScreenshotAsync's callback - #175

Open
dsheikherev wants to merge 3 commits into
mainfrom
docs/android-screenshot-async-upload
Open

dsheikherev wants to merge 3 commits into
mainfrom
docs/android-screenshot-async-upload

Conversation

@dsheikherev

Copy link
Copy Markdown
Contributor

Documents how to replace the screenshot of a report created with Bugsee.createReport on Android, as agreed in bugsee/bugsee-android#851. The Javadoc counterpart is bugsee/bugsee-android#852.

Why

  • Report.setScreenshot(Bitmap) encodes the image (WEBP) and writes it on the calling thread. On a Pixel 8 emulator (API 35, SDK 7.6.0) that took 125-178 ms for an app-like 1080×2400 bitmap.
  • The createReport listener runs on the main thread.
  • setScreenshotAsync returns at once, but a report uploaded right after it was often sent without the new screenshot: 3 and 5 of 10 in two runs. Uploading from its callback kept the screenshot in 10 of 10.

Code path and measurements: bugsee/bugsee-android#851.

Changes

docs/sdk/android/manual/bug-reporting.mdx, section "Programmatic report creation":

  • the list of commonly used members now includes setScreenshotAsync(Bitmap, Runnable);
  • a new subsection "Replacing the screenshot", with Java and Kotlin examples:
    • why to use setScreenshotAsync in onCreated;
    • upload from its callback, not right after the call;
    • which thread runs the callback: the calling thread when it has a Looper, otherwise the main thread (IssueReportScreenshot.java:150-155 at SDK v7.6.0).

Not done

report-handler.mdx lists setScreenshotAsync among the members a handler can use. In a handler the same rule should apply: call the handler's completion from setScreenshotAsync's callback. I did not test that case, so the page is unchanged.

Checks

  • npm run build passes: the new anchor is in the output, and no broken links are reported.
  • npx cspell on the page passes.

🤖 Generated with Claude Code

…back

Report.setScreenshot encodes and writes the image on the calling thread,
and the createReport listener runs on the main thread. A report uploaded
right after setScreenshotAsync can be sent without the new screenshot.
"Programmatic report creation" now lists setScreenshotAsync and shows
uploading from its callback (bugsee/bugsee-android#851).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dsheikherev
dsheikherev requested a review from krassx November 25, 2026 10:40
@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 304de371-6b62-4278-9fcd-e67e05efdfb8
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

return; // SDK not launched, or creation failed
}
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."

@claude

claude Bot commented Nov 25, 2026

Copy link
Copy Markdown

Review summary

This is a small docs-only change: one new subsection and one bullet in docs/sdk/android/manual/bug-reporting.mdx. I read the diff, the surrounding page, report-handler.mdx and the existing anchors. I did not run the build or cspell, and I did not check the SDK source (IssueReportScreenshot.java, v7.6.0). The claims about threading and about the screenshot being dropped therefore come from the PR description and bugsee-android#851, not from my own check.

Overall risk: Low

Merge recommendation: Approve, with one optional nit.

Findings

  • P3, bug-reporting.mdx:237: bitmap is undefined in both the Java and Kotlin examples, and the page says nothing about who owns it. It would help to show where it comes from and, if the SDK encodes it asynchronously, to warn against recycling it before the callback fires. Details are in the inline comment.

Observations, no action needed

  • The #replacing-the-screenshot anchor matches the heading, and the cross-link from the members list is consistent.
  • The two examples follow the existing Java/Kotlin tab pattern and the same groupId.
  • The ">100 ms" figure comes from a single emulator measurement. The wording is hedged ("for a screen-sized bitmap"), so it is acceptable.
  • The PR says it left report-handler.mdx unchanged because the handler case is untested. That is the right call, but the same pitfall may apply there, so a follow-up would be worthwhile.

Positives

  • The page explains why to use the async call and gives a concrete rule: upload from the callback.
  • The scope is narrow, the threading claim is tied to a specific SDK version, and the PR is open about what was not tested.

The list of commonly used Report members named only the asynchronous
call. It now names both and says how they differ.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 25, 2026

Copy link
Copy Markdown

Review update (after commit ad7265e)

This is a docs-only change to docs/sdk/android/manual/bug-reporting.mdx. I re-read the diff and the surrounding page. I did not run the build or cspell, and I did not check the SDK source. The threading and dropped-screenshot claims rest on the PR description and bugsee-android#851.

New since my last review: commit ad7265e adds setScreenshot(Bitmap) to the members bullet next to setScreenshotAsync. The text is accurate against the subsection below it, and the #replacing-the-screenshot anchor still matches the heading. I found no new issues.

Earlier finding, still open: the P3 inline comment at line 237 still applies. bitmap is undefined in both examples, and the page doesn't say who owns it while the async encode runs. I won't repeat it here.

Overall risk: Low
Merge recommendation: Approve. The P3 nit is optional.

Positives: the page gives a concrete rule (upload from the callback). The threading claim is pinned to a specific SDK version. The PR is open about leaving report-handler.mdx untested and unchanged.

…wns it

The examples used an undeclared `bitmap`. They now produce it, and the
section says that setScreenshotAsync reads the bitmap on a background
thread without copying it, so it must not be recycled or changed until
the callback runs (Report.java:360-361 at SDK v7.6.0).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@claude

claude Bot commented Nov 25, 2026

Copy link
Copy Markdown

Review update (after commit e56e321)

This is a docs-only change to docs/sdk/android/manual/bug-reporting.mdx. I re-read the final page. I ran cspell on it and it reported 0 issues. I did not run the Docusaurus build and did not check the SDK source. The threading and ownership claims rest on the PR description and the author's reply, which cites IssueReportScreenshot at v7.6.0.

Earlier finding fixed: my P3 about the undefined bitmap is resolved. Both examples now produce the bitmap, and the page says not to recycle or change it until the callback runs. It also says the report neither keeps nor recycles it, so ownership is clear.

New findings: none. The #replacing-the-screenshot anchor matches the heading. The examples follow the existing groupId="lang-android" tab pattern. The Kotlin trailing-lambda form setScreenshotAsync(bitmap) { ... } is valid for a Runnable parameter.

Overall risk: Low
Merge recommendation: Approve.
Most important issues to fix: none blocking. As a follow-up, the same "upload from the callback" rule probably applies in report-handler.mdx, and the PR already notes this is untested.

Positives:

  • The page gives a concrete rule (upload from the callback) with the reason behind it.
  • The threading claim is pinned to a specific SDK version.
  • The PR is open about the case it left untested.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant