Remove redundant paint-scope state warnings, keep clip over-pop hard fail (#5058)#5147
Merged
Conversation
…fail (#5058) The simulator's per-paint-scope state diagnostic (#5058, #5102) compared clip/transform/color/font/composite before and after every Component.paint / paintBackground / Painter.paint / glass-pane dispatch, logged a "did not restore Graphics state" warning, and auto-restored the drift. In practice these warnings were noise: components legitimately set their foreground color and font from their Style without restoring (the long-standing CN1 paint contract, harmless because the next draw sets its own), so the color/font reports were false positives against core classes that cannot reasonably be "fixed". The auto-restore also made the simulator mutate live Graphics state mid-render, diverging from device behavior. The genuinely valuable part -- the clip stack hard fail -- is retained: JavaSEPort.popClip still throws IllegalStateException when there is no matching pushClip, catching real clip-stack corruption at its source before it can crash on device. This removes the begin/endPaintScope snapshot/diff/log/auto-restore machinery and its no-op hooks, reverting the paint dispatch sites in Component/Form to direct calls, and trims PaintScopeTest to the two over-pop guard tests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Compared 11 screenshots: 11 matched. |
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Native Android coverage
✅ Native Android screenshot tests passed. Native Android coverage
Benchmark ResultsDetailed Performance Metrics
|
Contributor
✅ Continuous Quality ReportTest & Coverage
Static Analysis
Generated automatically by the PR CI workflow. |
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Collaborator
Author
|
Compared 122 screenshots: 122 matched. Benchmark Results
Build and Run Timing
Detailed Performance Metrics
|
Contributor
Cloudflare Preview
|
Collaborator
Author
|
Compared 94 screenshots: 94 matched. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The simulator's per-paint-scope state diagnostic added in #5058 (deduped in #5102) wrapped every
Component.paint/paintBackground/Painter.paint/ glass-pane dispatch, compared clip/transform/color/font/composite before and after, logged apaint-scope: ... did not restore Graphics statewarning, and auto-restored any drift.In practice the warnings were redundant noise:
Stylewithout restoring them — that's the long-standing Codename One paint contract, and it's harmless because the next component sets its own before drawing. So thecolor not restored/font not restoredreports were false positives against core classes (Label,Button,TextField,BGPainter,Container,Toolbar, …) that can't reasonably be "fixed", and they flooded the EDT log.The genuinely valuable part is kept:
JavaSEPort.popClipstill throwsIllegalStateExceptionwhen there is no matchingpushClip. That's a hard fail that catches real clip-stack corruption at its source before it can manifest as drift/crashes on device.Changes
JavaSEPort.java— removed thePaintScopeSnapshotclass, thepaintScopes/paintScopeChecksEnabled/reportedPaintScopeLeaksfields, thebegin/endPaintScopeoverrides (snapshot + diff + auto-restore + logging), and the helpers (clipStackDepth,trimClipStack,appendDiff,ownerClass,equalsNullSafe,sameShape,describe). ReverteddisposeGraphics. Kept thepopClip()over-pop hard-fail guard.Component.java(5 sites) /Form.java(glass pane) — reverted thebegin/endPaintScopetry/finally wrapping back to direct paint calls.CodenameOneImplementation.java— removed the no-opbegin/endPaintScopehook methods.PaintScopeTest.java— trimmed to the two over-pop guard tests; dropped the leak/auto-restore/dedup tests that depended on the removed API.Net: ~475 lines removed across 5 files; zero remaining references to the paint-scope diagnostic.
🤖 Generated with Claude Code