Skip to content

Fix ios.blockScreenshotsOnEnterBackground to hide peer components#5107

Merged
shai-almog merged 1 commit into
masterfrom
fix/ios-block-screenshots-peer-components
May 30, 2026
Merged

Fix ios.blockScreenshotsOnEnterBackground to hide peer components#5107
shai-almog merged 1 commit into
masterfrom
fix/ios-block-screenshots-peer-components

Conversation

@shai-almog
Copy link
Copy Markdown
Collaborator

Summary

  • ios.blockScreenshotsOnEnterBackground=true hid the EAGL/Metal surface on applicationDidEnterBackground but left peer components visible, so a BrowserComponent's native WKWebView (and any other peer) still showed up in the iOS app-switcher snapshot.
  • Once a peer is added with paintPeersBehindEnabled (the default), EAGLView.m / METALView.m re-parents into a newRoot that holds eaglView and peerComponentsLayer as siblings, and points GLViewController.view at that newRoot.
  • Switched the hide/show in cn1ApplicationDidEnterBackground / cn1ApplicationWillEnterForeground from eaglView.hidden to view.hidden. When no peers exist view == eaglView so behavior is unchanged; when peers exist view == newRoot and both children get hidden together.

Test plan

  • Build an iOS app with codename1.arg.ios.blockScreenshotsOnEnterBackground=true and a BrowserComponent showing a recognizable page.
  • Background the app (Home / app switcher) and confirm the app-switcher card no longer reveals the BrowserComponent contents.
  • Re-foreground and confirm the UI (both lightweight components and the BrowserComponent) renders normally and remains interactive.
  • Repeat without paintPeersBehindEnabled (legacy peer path) to confirm no regression on apps that don't enable peer-behind painting.

🤖 Generated with Claude Code

The background-snapshot hide path only toggled eaglView.hidden, but once
a peer component is added with paintPeersBehindEnabled the GL controller's
root view is a newRoot containing both eaglView and a sibling
peerComponentsLayer. BrowserComponent's native WKWebView lives in that
layer, so it stayed visible in the iOS app-switcher snapshot.

Hide the controller's view instead -- it resolves to eaglView when no
peers exist and to newRoot (covering both children) once they do.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 122 screenshots: 122 matched.
✅ Native iOS Metal screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 139 seconds

Build and Run Timing

Metric Duration
Simulator Boot 64000 ms
Simulator Boot (Run) 0 ms
App Install 13000 ms
App Launch 8000 ms
Test Execution 276000 ms

Detailed Performance Metrics

Metric Duration
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 native encode 502.000 ms
Base64 CN1 encode 1307.000 ms
Base64 encode ratio (CN1/native) 2.604x (160.4% slower)
Base64 native decode 263.000 ms
Base64 CN1 decode 869.000 ms
Base64 decode ratio (CN1/native) 3.304x (230.4% slower)
Base64 SIMD encode 381.000 ms
Base64 encode ratio (SIMD/native) 0.759x (24.1% faster)
Base64 encode ratio (SIMD/CN1) 0.292x (70.8% faster)
Base64 SIMD decode 355.000 ms
Base64 decode ratio (SIMD/native) 1.350x (35.0% slower)
Base64 decode ratio (SIMD/CN1) 0.409x (59.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 52.000 ms
Image createMask (SIMD on) 10.000 ms
Image createMask ratio (SIMD on/off) 0.192x (80.8% faster)
Image applyMask (SIMD off) 111.000 ms
Image applyMask (SIMD on) 59.000 ms
Image applyMask ratio (SIMD on/off) 0.532x (46.8% faster)
Image modifyAlpha (SIMD off) 113.000 ms
Image modifyAlpha (SIMD on) 54.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.478x (52.2% faster)
Image modifyAlpha removeColor (SIMD off) 134.000 ms
Image modifyAlpha removeColor (SIMD on) 78.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.582x (41.8% faster)
Image PNG encode (SIMD off) 954.000 ms
Image PNG encode (SIMD on) 825.000 ms
Image PNG encode ratio (SIMD on/off) 0.865x (13.5% faster)
Image JPEG encode 487.000 ms

@shai-almog
Copy link
Copy Markdown
Collaborator Author

shai-almog commented May 30, 2026

Compared 69 screenshots: 69 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 251 seconds

Build and Run Timing

Metric Duration
Simulator Boot 99000 ms
Simulator Boot (Run) 1000 ms
App Install 15000 ms
App Launch 10000 ms
Test Execution 1500000 ms

@shai-almog shai-almog merged commit ecc3927 into master May 30, 2026
17 checks passed
@shai-almog shai-almog deleted the fix/ios-block-screenshots-peer-components branch May 30, 2026 05:27
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