Skip to content

Commit ee2e9bd

Browse files
shai-almogclaude
andcommitted
charts: revert diagnostic logging + chart-line test config
The CN1SS:DBG diagnostic logging in ChartComponent.paint and XYChart.draw plus the empty-dataset / labels-off variants of ChartLineScreenshotTest narrowed the iOS GL+Metal blank-render to LineChart.drawSeries -> AbstractChart.drawPath -> g.drawShape(translatedPath, stroke) on the form-Graphics. The bug is in the iOS port's GlobalGraphics.nativeDrawShape / TextureAlphaMask path -- removing data from chart-line so drawSeries isn't invoked produced a non-blank form (title bar visible) on iOS Metal, while restoring drawSeries reliably reproduces the all-blank PNG. drawShape on iOS form-Graphics aborts the entire frame, not just the chart area; that's why even the form's title bar disappears. Revert the diagnostics now that the culprit is identified. The chart-line config goes back to its real two-series LineChart so Android, JavaSE and the (eventually-fixed) iOS path all keep meaning- ful coverage. The Canvas.rotate xTranslate-conjugation fix in 16deb08 was investigated and ruled out -- it stays in place because it's correct under the universal Graphics.setTransform conjugation, just not the cause of this iOS-specific blank. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 532f52f commit ee2e9bd

3 files changed

Lines changed: 19 additions & 44 deletions

File tree

CodenameOne/src/com/codename1/charts/ChartComponent.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,21 +306,7 @@ public void paint(Graphics g) {
306306
}
307307

308308

309-
try {
310-
System.out.println("CN1SS:DBG:ChartComponent.paint:start chart=" + chart.getClass().getSimpleName()
311-
+ " absX=" + getAbsoluteX() + " absY=" + getAbsoluteY()
312-
+ " bx=" + getBounds().getX() + " by=" + getBounds().getY()
313-
+ " bw=" + getBounds().getWidth() + " bh=" + getBounds().getHeight()
314-
+ " gxT=" + g.getTranslateX() + " gyT=" + g.getTranslateY()
315-
+ " gclipX=" + g.getClipX() + " gclipY=" + g.getClipY()
316-
+ " gclipW=" + g.getClipWidth() + " gclipH=" + g.getClipHeight());
317-
util.paintChart(g, chart, getBounds(), getAbsoluteX(), getAbsoluteY());
318-
System.out.println("CN1SS:DBG:ChartComponent.paint:end chart=" + chart.getClass().getSimpleName());
319-
} catch (Throwable t) {
320-
System.out.println("CN1SS:DBG:ChartComponent.paint:exception chart=" + chart.getClass().getSimpleName()
321-
+ " err=" + t);
322-
t.printStackTrace();
323-
}
309+
util.paintChart(g, chart, getBounds(), getAbsoluteX(), getAbsoluteY());
324310

325311
if (transformed) {
326312
g.setTransform(tmpTransform);

CodenameOne/src/com/codename1/charts/views/XYChart.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,12 @@ protected void setDatasetRenderer(XYMultipleSeriesDataset dataset,
101101
/// - `paint`: the paint
102102
@Override
103103
public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint) {
104-
System.out.println("CN1SS:DBG:XYChart.draw:enter cls=" + getClass().getSimpleName()
105-
+ " x=" + x + " y=" + y + " w=" + width + " h=" + height
106-
+ " antialias=" + mRenderer.isAntialiasing());
107104
paint.setAntiAlias(mRenderer.isAntialiasing());
108105
int legendSize = getLegendSize(mRenderer, height / 5, mRenderer.getAxisTitleTextSize());
109106
int[] margins = mRenderer.getMargins();
110107
int left = x + margins[1] + (int) mRenderer.getAxisTitleTextSize() + (mRenderer.isShowLabels() ? (int) mRenderer.getLabelsTextSize() : 0);
111108
int top = y + margins[0];
112109
int right = x + width - margins[3];
113-
System.out.println("CN1SS:DBG:XYChart.draw:bounds left=" + left + " top=" + top
114-
+ " right=" + right + " legendSize=" + legendSize + " axisTitleTextSize=" + (int) mRenderer.getAxisTitleTextSize()
115-
+ " margins=[" + margins[0] + "," + margins[1] + "," + margins[2] + "," + margins[3] + "]");
116110
int sLength = mDataset.getSeriesCount();
117111
String[] titles = new String[sLength];
118112
for (int i = 0; i < sLength; i++) {
@@ -164,7 +158,6 @@ public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint
164158
}
165159
maxScaleNumber++;
166160
if (maxScaleNumber < 0) {
167-
System.out.println("CN1SS:DBG:XYChart.draw:earlyReturn maxScaleNumber=" + maxScaleNumber);
168161
return;
169162
}
170163
double[] minX = new double[maxScaleNumber];
@@ -501,7 +494,6 @@ public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint
501494
if (rotate) {
502495
transform(canvas, angle, true);
503496
}
504-
System.out.println("CN1SS:DBG:XYChart.draw:exit cls=" + getClass().getSimpleName());
505497
}
506498

507499
protected List<Double> getXLabels(double min, double max, int count) {

scripts/hellocodenameone/common/src/main/java/com/codenameone/examples/hellocodenameone/tests/charts/ChartLineScreenshotTest.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,36 +18,33 @@ public class ChartLineScreenshotTest extends AbstractChartScreenshotTest {
1818

1919
@Override
2020
protected AbstractChart buildChart() {
21-
// Diagnostic: empty dataset so drawSeries is never invoked. If
22-
// chart-line still produces a blank PNG with no series + everything
23-
// else off, the bug is in XYChart.draw's pre-series setup or in the
24-
// form / paint pipeline interaction with ChartComponent. If chart-line
25-
// *now* renders an empty (but non-blank) form, drawSeries' drawPath
26-
// is the iOS-specific culprit.
2721
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
22+
XYSeries north = new XYSeries("North");
23+
north.add(2018, 12);
24+
north.add(2019, 16);
25+
north.add(2020, 22);
26+
north.add(2021, 18);
27+
north.add(2022, 28);
28+
dataset.addSeries(north);
29+
30+
XYSeries south = new XYSeries("South");
31+
south.add(2018, 8);
32+
south.add(2019, 11);
33+
south.add(2020, 13);
34+
south.add(2021, 16);
35+
south.add(2022, 19);
36+
dataset.addSeries(south);
2837

2938
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
3039
renderer.setLabelsTextSize(20);
3140
renderer.setAxisTitleTextSize(20);
3241
renderer.setLegendTextSize(20);
3342
renderer.setMargins(new int[]{36, 60, 24, 24});
34-
// Diagnostic: turn off labels + legend + grid + axes so XYChart.draw
35-
// paints essentially nothing beyond drawSeries (the line strokes).
36-
// If chart-line renders an empty white form on iOS GL/Metal under
37-
// this minimal config we know the form / paint pipeline is working
38-
// and the bug is in one of the disabled code paths
39-
// (drawText / drawLegend / drawGrid / drawAxes). If it stays blank
40-
// even with everything off, something fundamental about XYChart's
41-
// first paint is breaking iOS rendering.
42-
renderer.setShowLabels(false);
43-
renderer.setShowLegend(false);
44-
renderer.setShowGrid(false);
45-
renderer.setShowAxes(false);
46-
// renderer.setXTitle("Year");
47-
// renderer.setYTitle("Value");
43+
renderer.setXTitle("Year");
44+
renderer.setYTitle("Value");
4845
renderer.setXLabels(5);
4946
renderer.setYLabels(5);
50-
// renderer.setShowGrid(true); // diagnostic: keep grid off
47+
renderer.setShowGrid(true);
5148

5249
XYSeriesRenderer northRenderer = new XYSeriesRenderer();
5350
northRenderer.setColor(ColorUtil.rgb(0x0a, 0x66, 0xff));

0 commit comments

Comments
 (0)