Recent

Author Topic: Chart left axis labelled differently with latest trunk  (Read 1053 times)

Wilko500

  • Full Member
  • ***
  • Posts: 180
Chart left axis labelled differently with latest trunk
« on: September 22, 2025, 12:01:48 am »
After testing out the canvas memory leak with trunk I see a difference in how the chart left axis is labelled
Code: Pascal  [Select][+][-]
  1. Lazarus version: 4.99
  2. Lazarus revision: main_4_99-2615-gcccedc5bf0
  3. Lazarus build date: 2025/09/21 22:14:23
  4. Lazarus was compiled for x86_64-darwin
  5. Lazarus was compiled with FPC 3.3.1
The code for this chart is all default values plus
Code: Pascal  [Select][+][-]
  1.   //Set up Chart
  2.   Chart1.LeftAxis.Range.Min:=0;
  3.   Chart1.LeftAxis.Range.Max:=4200;
  4.   Chart1.LeftAxis.Range.UseMax:=True;
  5.   Chart1.LeftAxis.Range.UseMin:=True;
  6.   Chart1.LeftAxis.Grid.Color:=clTeal;
  7.   Chart1.LeftAxis.Minors.Axes[0].Grid.Color:=clTeal;
  8.   Chart1.LeftAxis.ZPosition:=0;
  9.   Chart1.LeftAxis.Visible:=True;
  10.  
  11.   Chart1.BottomAxis.Range.Min:=GetChartDate(Now, '00:00:00');
  12.   Chart1.BottomAxis.Range.Max:=GetChartDate(IncDay(Now), '00:00:00');
  13.   Chart1.BottomAxis.Range.UseMin:=True;
  14.   Chart1.BottomAxis.Range.UseMax:=True;
  15.   Chart1.BottomAxis.Grid.Color:=clTeal;
  16.   Chart1.BottomAxis.Minors.Axes[0].Grid.Color:=clTeal;
  17.   Chart1.BottomAxis.Title.Caption:='Time on ' + FormatDateTime('dd mmm yyyy', Now);
  18.   Chart1.BottomAxis.ZPosition:=1;
  19.   Chart1.BottomAxis.Marks.Style:=smslabel;
  20.   Chart1.BottomAxis.Marks.Source:=ListChartSource1;
  21.  
  22.   PopulateTimeLabels(Chart1.BottomAxis.Range, ListChartSource1);
  23.   Chart1.BackColor:=ClBlack;
  24.   Power.SeriesColor:=clYellow;
  25.   Chart1.Margins.Left:=0;
  26.   Chart1.Margins.Right:=0;
  27.   Chart1.Margins.Top:=0;
  28.   Chart1.Margins.Bottom:=1;
  29.  
  30.   Power.LinePen.Width:=2;
  31.   Power.ZPosition:=2;
The PopulateTimeLabels procedure draws the bottom axis only. 
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

wp

  • Hero Member
  • *****
  • Posts: 13207
Re: Chart left axis labelled differently with latest trunk
« Reply #1 on: September 22, 2025, 01:14:49 am »
Cannot reproduce the irregularly space labels. Using a chart, 500 px high, I set Chart.LeftAxis.Range.Max = 4200, .Min = 0, .UseMax = true, .UseMin = true - and I get evenly spaced label with steps 200. This is on Mac and on Windows. When I increase the Chart.LeftAxis.Intervals.MaxLength to 100 I get label steps of 500.

Are you sure that you did not make any changes to the chart while the memory leak was existing?

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Chart left axis labelled differently with latest trunk
« Reply #2 on: September 22, 2025, 02:54:47 am »
I created a new project, added a single chart, make no changes to properties and what is displayed in the IDE is incorrect.  The left axis should run from -1 to 1.  Pic shows what I actually see.  The version info is
Code: Pascal  [Select][+][-]
  1. This version fails
  2. Lazarus version: 4.99
  3. Lazarus revision: main_4_99-2615-gcccedc5bf0
  4. Lazarus build date: 2025/09/21 22:14:23
  5. Lazarus was compiled for x86_64-darwin
  6. Lazarus was compiled with FPC 3.3.1
If I load the same project into my earlier version the chart displays as it should
Code: Pascal  [Select][+][-]
  1. This version works
  2. Lazarus version: 4.3
  3. Lazarus revision: lazarus_4_2-40-g95f1de5805
  4. Lazarus build date: 2025/09/11 23:02:36
  5. Lazarus was compiled for x86_64-darwin
  6. Lazarus was compiled with FPC 3.2.3
My IDE was built with FpcUpDeluxe today selecting trunk for both FPC and Lazarus and created in an empty folder.  My latest build, 4.99 fails in the same manner with two other projects all of which work correctly with my 4.3 build (memory leaks excepted).
Perhaps I should try a new build? 
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Chart left axis labelled differently with latest trunk
« Reply #3 on: September 22, 2025, 09:53:11 am »
Started again.  New FpcUpDeluxe build using FPC 3.3.1 Laz Trunk into new folder.
Create new project, add one chart,  set Chart.LeftAxis.Range.Max = 4200, .Min = 0, .UseMax = true, .UseMin = true in Object Inspector and incorrect labelling is repeated.
Code: Pascal  [Select][+][-]
  1. Lazarus version: 4.99
  2. Lazarus revision: main_4_99-2615-gcccedc5bf0
  3. Lazarus build date: 2025/09/22 08:36:13
  4. Lazarus was compiled for x86_64-darwin
  5. Lazarus was compiled with FPC 3.3.1
  6.  
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

wp

  • Hero Member
  • *****
  • Posts: 13207
Re: Chart left axis labelled differently with latest trunk
« Reply #4 on: September 22, 2025, 10:27:15 am »
I re-tested myself, and still cannot reproduce. To make sure that your issues are related to the memory leak fix:
  • Open file (lazarus-dir)/lcl/interfaces/cocoa/cocoagdiobjects.pas in the IDE
  • Find the implementation of constructor TCocaContext.Create(...)
  • Comment out the line "FFont := DefaultFont" - this was the only change made to fix the memory leak
  • Recompile your test application to see the effect of this change at runtime. If you want to see it at designtime, you must rebuild the IDE.
  • Are the axis labels correct?

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Chart left axis labelled differently with latest trunk
« Reply #5 on: September 22, 2025, 11:05:27 am »
Thank you for your suggestion. I’ll try that tonight. That was going to be my next question. Presumably I can add that line in my pre-leak ide to fix leaks.
Feedback tonight
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Chart left axis labelled differently with latest trunk
« Reply #6 on: September 23, 2025, 01:15:18 pm »
I have done additional testing.
Commenting out the fix line in my latest ide build did not change the faulty labels.
Including the fix line in my previous ide build fixed the memory leaks and did not change the correctly labelled axis.

From that I conclude that the faulty axis labels are unrelated to the memory leak fix.  Great news :)

However I continued testing to try and find a reason for the faulty labels.  This was done by a lot of fresh installs using FpcUpDeluxe trying a variety of combinations of FPC & Lazarus versions.  The results are:
Unpredictable!  Sometimes the build finishes successfully, sometimes not, usually with an error
Code: Pascal  [Select][+][-]
  1. rtl-objpas/units/x86_64-darwin/rtti.s:12:1: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs
I could not see any pattern for success or failure.
However any of the builds that did succeed showed the axis labels incorrectly.  Further research highlighted "non-private" labels error as being an issue with early builds ofMacOs Sequoia and associated Xcode.  Hummp! Ran out of ideas so I went out for coffee.  Then the penny dropped. 
The only difference I can think of is that my MacBook OS was upgraded between the ide builds.  The builds that label correctly were done before the upgrade, the build that label incorrectly were done after the upgrade.

The upgrade was from MacOs Sequoia 15.6.x to 15.7 and more significantly Xcode 16.4 to 26

I feel quite certain that the cause is FcpUpDeluxe incompatibility with Xcode 26.0.  I'm guessing that you were using Xcode 15/16?

It seems unlikely that Chart labels is the only thing affected so wonder if you have any other thought about what might be happening "under the hood".  I am way out of my depth on the internals of Lazarus/FPC/FpcUpDeluxe.  I am thinking that I should place an issue on the FpcUpDeluxe git page?

In the meantime I have a working development environment without the memory leaks and for that my thanks to you and the team.



   
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

wp

  • Hero Member
  • *****
  • Posts: 13207
Re: Chart left axis labelled differently with latest trunk
« Reply #7 on: September 23, 2025, 03:24:45 pm »
the faulty axis labels are unrelated to the memory leak fix.  Great news :)
Thank you, good news. It allows me to close the bug report.

The only difference I can think of is that my MacBook OS was upgraded between the ide builds.  The builds that label correctly were done before the upgrade, the build that label incorrectly were done after the upgrade.

The upgrade was from MacOs Sequoia 15.6.x to 15.7 and more significantly Xcode 16.4 to 26

I feel quite certain that the cause is FcpUpDeluxe incompatibility with Xcode 26.0.  I'm guessing that you were using Xcode 15/16?
Sorry, I don't feel myself as a mac user, I only have macOS 12 as a VM on a Windows host and am happy that I have sufficient knowledge to do some Lazarus tests there...

You should report the issue to the bugtracker. But providing a TAChart sample as a test bed is way too complex, such an issue should become apparent in some simpler tests, e.g. by drawing to a canvas, and this is where a developer could step in.

I do not believe that the issue has something to do with FPCUpDeluxe, but rather maybe with Laz/main or FPC/main. BTW, when you link your Laz/main with FPC 3.2.2 (this is the combination that I am using for cocoa), does the labeling issue disappear? In this case, the incompatibility could be an incompatibility of FPC/main with XCode 26. For this test, you probably should make a new separate Laz/main+FPC3.2.2 installation with FPCUpDeluxe to avoid damaging your work environment - you can simply delete it afterwards.

You could also try to debug TAChart to try to understand which step fails to cause the irregularly spaced axis labels, and then based on this result you could write a simpler test application for the bug report (or I can do this for you). You could just drop a client-aligned TChart on a form of well-defined size (e.g. 500x300 - because labels depend on the size of the chart), and hide the bottom axis (otherwise you will be confused by that axis appearing in the debugger). In the project options, go to "Additions and overrides" and define a custom option, either in the project or in the session, named "-gwdwarfsets" (without quotes) - this way you will be able to step into the TAChart units. Then load the TAChart unit TAIntervalSources and set a break-point at the first instruction of TIntervalChartSource.CalculateIntervals - this is where the labels are calculated, and then step through the code at runtime. When I do this on my system, the first instruction CalcMinMaxCount returns minCount = 8 and maxcount = 43. The branch "if aipInteger in Params.Options" is skipped. "if aipUseNiceSteps", however, is entered. The first value of s is 1 and does not change in the "while" loop; when this "if" is exited, bestcount has the value 11. The branch "if aipUseCount" should not be entered (your description sounds, though, as if it is). At the end, ABestStep hat the value 0.2000...01, and ABestStart is -1.2. When you compare these observations with what happens on your machine we maybe can find the place where the calculation goes wrong.

When you do these tests report the results, I'll be happy to give you further instructions. No problem if you don't want to or don't have the time for it: this seems to be a fundamental issue with XCode 26, and I am rather sure that it will reappear later at another place.

Wilko500

  • Full Member
  • ***
  • Posts: 180
Re: Chart left axis labelled differently with latest trunk
« Reply #8 on: September 26, 2025, 06:30:02 pm »
@wp, update.  Thank you for your response and offer of help.  To progress this I tried a few things.
The Sequoia upgrade to 15.7 was accompanied with upgrade to Xcode 26.  I wanted to rule this out so I regressed my Xcode back to 16.4 and then to 16.3.  Made no difference but I note that I had significant difficulty getting FpcUpDeluxe to build any combinations of Fpc & Laz.
I'm not sure why but I suspect that my Xcode was not "completely" removed.  Although I am a long time Mac user I am not a Mac guru!! I have never got to the point of being comfortable at the command line.

So I reinstalled Xcode 26.0.1, a minor update that should not affect command line tools, and tried again in a more structured way.  What I found is that the Chart label issue only occurs when FPC 3.3.1 is used in the build.  It appears that 3.3.1 has been adopted into the trunk so it seems like further investigation is appropriate.  So 3.2.0, 3.2.2 & fixes work for Laz 4.99, fixes & trunk and Chart labels are ok.  Use FPC 3.3.1 and they are not displayed correctly.

I agree that a Chart test bed is way too complicated and a simpler test example is needed.  I feel that my additional testing has ruled out Xcode but pointed the finger at FPC 3.3.1 (and trunk by implication) so yes, I think this issue will arise again.

So far I have not done any serious debugging but I will see if I can begin to understand what is happening using the details and hints you posted.  First step I'll try to get answers to the questions you posted.  I'm quite sure that I will need further guidance.

If there are any Mac users with Sequoia 15.x /Xcode 26 perhaps they can try to duplicate the Chart label problem?
MacBook Pro mid 2015 with OS Monterey 12.7.6
FPC 3.2.3 Lazarus 3.7
FPC 3.2.2 Lazarus 3.4

 

TinyPortal © 2005-2018