Skip to content

Conversation

@shai-almog
Copy link
Collaborator

The screenshot() method in AndroidImplementation was missing PeerComponents (native Android views like BrowserComponent, MapView, etc.) in the captured image on devices running Android < API 26 (Oreo).

The issue was in the AndroidScreenshotTask.tryFallbackDraw() method, which only drew the CodenameOneSurface view itself. PeerComponents are added as siblings to the CodenameOneSurface within the parent RelativeLayout container, so they were not being captured.

The fix:

  • Draw the parent container (RelativeLayout) instead of just the view
  • Calculate and apply proper canvas translation to align the content
  • Maintain backward compatibility by falling back to view-only drawing if no parent is found

Note: The PixelCopy method (API 26+) already worked correctly as it captures the entire window, so this only affects older Android versions.

The screenshot() method in AndroidImplementation was missing PeerComponents
(native Android views like BrowserComponent, MapView, etc.) in the captured
image on devices running Android < API 26 (Oreo).

The issue was in the AndroidScreenshotTask.tryFallbackDraw() method, which
only drew the CodenameOneSurface view itself. PeerComponents are added as
siblings to the CodenameOneSurface within the parent RelativeLayout container,
so they were not being captured.

The fix:
- Draw the parent container (RelativeLayout) instead of just the view
- Calculate and apply proper canvas translation to align the content
- Maintain backward compatibility by falling back to view-only drawing
  if no parent is found

Note: The PixelCopy method (API 26+) already worked correctly as it captures
the entire window, so this only affects older Android versions.
@github-actions
Copy link

github-actions bot commented Nov 6, 2025

✅ Continuous Quality Report

Test & Coverage

Static Analysis

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Collaborator Author

shai-almog commented Nov 6, 2025

Android screenshot updates

  • BrowserComponent — updated screenshot. Screenshot differs (320x616 px, bit depth 8).

    BrowserComponent
    Preview info: JPEG preview quality 70; JPEG preview quality 70.
    Full-resolution PNG saved as BrowserComponent.png in workflow artifacts.

@shai-almog shai-almog merged commit d00c465 into master Nov 6, 2025
2 checks passed
shai-almog pushed a commit that referenced this pull request Nov 8, 2025
The CI instrumentation test was using Android's native View.draw() method
to capture screenshots, which doesn't properly include PeerComponents like
BrowserComponent (native WebView).

This change updates the test to use Codename One's screenshot API
(Display.getInstance().screenshot()) which properly captures native widgets
via the AndroidScreenshotTask implementation that was fixed in PR #4107.

Key changes:
- Replace direct View.draw() with CN1 screenshot API
- Add proper synchronization using CountDownLatch
- Convert CN1 Image to Android Bitmap for encoding
- Maintain same output format for CI pipeline compatibility

This ensures BrowserComponent and other native widgets are now visible
in CI screenshots.
shai-almog pushed a commit that referenced this pull request Nov 8, 2025
The CI instrumentation test was using Android's native View.draw() method
to capture screenshots, which doesn't properly include PeerComponents like
BrowserComponent (native WebView).

This change updates the test to use Codename One's screenshot API
(Display.getInstance().screenshot()) which properly captures native widgets
via the AndroidScreenshotTask implementation that was fixed in PR #4107.

Key changes:
- Replace direct View.draw() with CN1 screenshot API
- Add proper synchronization using CountDownLatch
- Convert CN1 Image to Android Bitmap for encoding
- Maintain same output format for CI pipeline compatibility

This ensures BrowserComponent and other native widgets are now visible
in CI screenshots.
shai-almog added a commit that referenced this pull request Nov 8, 2025
The CI instrumentation test was using Android's native View.draw() method
to capture screenshots, which doesn't properly include PeerComponents like
BrowserComponent (native WebView).

This change updates the test to use Codename One's screenshot API
(Display.getInstance().screenshot()) which properly captures native widgets
via the AndroidScreenshotTask implementation that was fixed in PR #4107.

Key changes:
- Replace direct View.draw() with CN1 screenshot API
- Add proper synchronization using CountDownLatch
- Convert CN1 Image to Android Bitmap for encoding
- Maintain same output format for CI pipeline compatibility

This ensures BrowserComponent and other native widgets are now visible
in CI screenshots.

Co-authored-by: Claude <[email protected]>
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.

3 participants