LiveCharts2 icon indicating copy to clipboard operation
LiveCharts2 copied to clipboard

Cannot visualize on IOS

Open canperk opened this issue 2 years ago • 29 comments

Describe the bug When I try to use charts as basic usage. Android works fine but on IOS it shows only an empty space

To Reproduce Steps to reproduce the behavior:

  1. Create MAUI Project.
  2. Add LiveCharts dependency from Nuget
  3. Add sample Line Chart code from LiveCharts sample
  4. Try on IOS

Expected behavior Chart is shown

Screenshots image

Smartphone:

  • Device: iPhone 11
  • OS: iOS16

canperk avatar Dec 04 '22 19:12 canperk

@beto-rodriguez as you mentioned in the issue here I added <AndroidLinkResources>false</AndroidLinkResources> to project file in Property Groups, stil same problem exists.

canperk avatar Dec 16 '22 22:12 canperk

https://github.com/canperk/LiveChartMAUI_IOS_issue is the reproduced version. A Basic line chart is not able to shown on IOS. YOu can use this as a reference. Maybe I am missing a silly detail. I just followed the Getting Started Stuffs

canperk avatar Dec 16 '22 23:12 canperk

Hi @beto-rodriguez Unfortunately we are also seeing this behavior where a basic line chart does not display on iOS, but works as expected on Android and Windows. We're using dotnet 7 (MAUI), but dropping back to dotnet 6 did not correct the issue. Do you have plans to investigate and resolve this? Kind regards, Scott

ScottyLightnin avatar May 21 '23 23:05 ScottyLightnin

We're seeing the same issue on iOS. Simplest of charts, static ISeries[], copied from Samples. Just a blank view.

frederikspang avatar Jun 01 '23 19:06 frederikspang

I experience the same. Windows and Android is working well. iOS is showing blank. What do you other guys do? Trying to fix, found workaround, alternatives or just waiting.

JerryAndersen avatar Jun 16 '23 13:06 JerryAndersen

This should be fixed soon, will be apriority for the next release.

beto-rodriguez avatar Jun 16 '23 19:06 beto-rodriguez

This is such good news, thank you. Without this fix we cannot use LiveCharts2 which saddens me because they are so superior to the alternatives I wish you well for a speedy fix! Kind regards Scott

On Sat, 17 Jun 2023 at 07:13, Alberto Rodríguez @.***> wrote:

This should be fixed soon, will be apriority for the next release.

— Reply to this email directly, view it on GitHub https://github.com/beto-rodriguez/LiveCharts2/issues/800#issuecomment-1595167730, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLWV7S72PCO6RJDO3B5Y3LXLSV6FANCNFSM6AAAAAASTRFZEM . You are receiving this because you commented.Message ID: @.***>

ScottyLightnin avatar Jun 18 '23 02:06 ScottyLightnin

Same issue here, is there a workaround or an expected time frame for a fix in the near future? Is the problem known and just needs to be implemented? Maybe we can help actively to fix as soon as possible, because this is actually a show stopper currently, if you want to build e.g. a MAUI app for Android and iOS...

erdmenchen avatar Jul 04 '23 16:07 erdmenchen

I got it working now. I did a lot of changes, so don´t know what fixed the issue... sorry ;-)

erdmenchen avatar Jul 06 '23 19:07 erdmenchen

This should be probably fixed if you update your MAUI/dotnet version, I have seen a lot of issues fixed when I upgraded from net 6.0 to net7.0, anyways I keep investigating this.

beto-rodriguez avatar Jul 09 '23 01:07 beto-rodriguez

still broken for us on the latest Maui stable and .net 7.0. Appreciate your investigation.

ScottyLightnin avatar Jul 09 '23 09:07 ScottyLightnin

Same issue here. Changed nuget version, changed .NET version etc.

Doesn't work.

roja300 avatar Jul 09 '23 09:07 roja300

I just updated to 2.0.0-beta.810 (from beta 802) and with latest .Net7 I have the same issue. Doesn't work at iOS (16.5.1) but works fine at Android (emulator). @erdmenchen I'm really curious why it is working for you. Can you please provide some versions of what you use? LiveChartsCore.SkiaSharpView.Maui MAUI version Maybe iOS version?

JerryAndersen avatar Jul 11 '23 09:07 JerryAndersen

After checking this out and setting up my Mac environment again I was able to deploy the sample provided in this repository to an iPad.

I was able to run this repo on iOS, this is the sample provided in this repo I just published it to an iPad without issues:

https://github.com/beto-rodriguez/LiveCharts2/assets/10853349/43fcea1d-83bc-4843-9357-515c33445867

Well, this is the dev branch version (not published to NuGet yet), but is just the MauiSample provided in this repo; In the last days I updated the Maui view of the library to net 7, that fixed some zooming and panning issues for me, I am not sure if this update fixed this issue, I see a couple of options to try to fix this error for your case:

  1. Wait for my next release (this weekend), it will force your dotnet version to be at least net 7.0, I am not sure if something in SkiaSharp or Maui has been improved.

  2. Try to clone this repo (use the dev branch), and deploy the Maui sample to your iOS device, this will give you a clue if the issue is on your development environment, with my current setup it works: dotnet version 7.0.36, visual studio 17.6.5, my iPadOS is on 16.5.1 and my MacOS is Ventura 13.4.1.

beto-rodriguez avatar Jul 14 '23 00:07 beto-rodriguez

Update

You can discard option 1, the library is working with the latest NuGet package (beta.810), the following repo is just a really basic app and is working on iOS also:

https://github.com/beto-rodriguez/MauiApp-LiveCharts

https://github.com/beto-rodriguez/LiveCharts2/assets/10853349/15d09fec-cf9e-43fe-a7aa-c38bce184162

Please verify your development environment (dotnet version, visual studio, MacOS) and try to publish https://github.com/beto-rodriguez/MauiApp-LiveCharts to your iOS device again, see the readme file in that repo for more info.

beto-rodriguez avatar Jul 14 '23 01:07 beto-rodriguez

Your issue could also be caused by #1063, it will be fixed once there is a stable release of SkiaSharp 2.88.4

beto-rodriguez avatar Jul 15 '23 15:07 beto-rodriguez

I just cloned your repo and tried your sample and it doesn't work at my environment. It deploys fine but at iOS the view is blank.

I have .NET 7.0.306. VS 17..6.5. IOS 16.5.1. I don't use Mac for now but only iTunes 12.12.9.4 but I guess that can't be the cause. Everything else works fine. What do you think?

JerryAndersen avatar Jul 22 '23 11:07 JerryAndersen

I don't discard that the issue exists, it is just that we have not found what triggers it, so any feedback would be useful to find this.

Being honest, I don't think that the issue is in this library, we are not doing anything special for the iOS view, we are only using the SkiaSharp view for MAUI, this issue seems out of the scope of this library.

You could also be affected by https://github.com/dotnet/maui/issues/7350. They now removed the verified tag, which probably means that it is not happening on the latest version. I have not test this again, but in the past, I was able to reproduce the issue and gave them feedback on the issue I found.

beto-rodriguez avatar Jul 22 '23 17:07 beto-rodriguez

I just published beta.860, this version removes the support for the XAML designer (which just noticed is not actually supported on MAUI), please let me know if that fixed the issue.

beto-rodriguez avatar Jul 22 '23 18:07 beto-rodriguez

I just published beta.860, this version removes the support for the XAML designer (which just noticed is not actually supported on MAUI), please let me know if that fixed the issue.

I just tried 860 and unfortunately it didn't fix the issue.

JerryAndersen avatar Jul 22 '23 22:07 JerryAndersen

I had the same problem. The only way i could fix it on iOS (for now) is to add HorizontalOptions = FillAndExpand + VerticalOptions = FillAndExpand on the chart object in xaml. Hope this comment helps someone avoiding hours of debugging!

concer22 avatar Aug 03 '23 10:08 concer22

Thanks for your feedback @concer22. Sadly we tried that but for us the issue remains. Latest Preview of VS, on .Net 7, using: <PackageReference Include="LiveChartsCore.SkiaSharpView.Maui" Version="2.0.0-beta.900" /> Works great in Windows and Android, but just a blank chart on iOS

ScottyLightnin avatar Aug 03 '23 20:08 ScottyLightnin

Ok weird, same specs here and it works. Maybe if i post the whole code you can get it to work for you. It seems the chart is very sensitive for properties being there or not that can influence the height/width. The wrong property there means an invisible chart on iOS. (works fine in android)

<lvc:CartesianChart ZIndex="10" HorizontalOptions="FillAndExpand" VerticalOptions="Start" HeightRequest="550" x:Name="lineChart" TooltipPosition="Top" TooltipTextSize="10" LegendTextSize="10" Series="{Binding Series}" XAxes="{Binding XAxes}" YAxes="{Binding YAxes}"> </lvc:CartesianChart>

		`SeriesValue = new ObservableCollection<ISeries>
				{
					new LineSeries<ObservableValue>
					{
						Values = ChartDataValue.Select(x => new ObservableValue((double)x.Value)),
						Stroke = new SolidColorPaint(SKColor.Parse("#95C11F"), 3),
						Fill = new SolidColorPaint(SKColor.Parse("#95C11F").WithAlpha(0x40)),
						DataLabelsSize = 8,
						DataLabelsPaint = new SolidColorPaint(SKColor.Parse("#000")),
						GeometrySize = 6,
						GeometryStroke = new SolidColorPaint(SKColor.Parse("#95C11F")),
						GeometryFill = new SolidColorPaint(SKColor.Parse("#000").WithAlpha(0x80)),
						DataLabelsPosition = LiveChartsCore.Measure.DataLabelsPosition.Top,

					}
				};

				XAxesValue = new ObservableCollection<Axis>
				{
					new Axis
					{
						Labels = ChartDataValue.Select(x => x.Label).ToArray(),
						Labeler = (value) => value.ToString(),
						TextSize=10,
						MinStep = 1,
						ForceStepToMin = true,
						ShowSeparatorLines = true,
						LabelsRotation = 70,
						Padding = new LiveChartsCore.Drawing.Padding(0,10,5,10),
						UnitWidth = SelectedStatisticType == StatisticTypeEnum.DAY ? TimeSpan.FromHours(1).Ticks : TimeSpan.FromDays(1).Ticks,
					}
				};

				YAxesValue = new ObservableCollection<Axis>
				{
					new Axis
					{
						TextSize=12,
						MinLimit = 0
					}
				};`

concer22 avatar Aug 04 '23 07:08 concer22

ok finally an update and some good news. Our charts on iOS started working! For us, it took building and deploying from a Mac first, rather than from our main Windows dev boxes. @beto-rodriguez I don't know if this gives you a hint as to what could be wrong, or helps with your reproduction steps. But for us, this is great news as we're able to go ahead and use LiveCharts2 in our production apps.

ScottyLightnin avatar Aug 10 '23 00:08 ScottyLightnin

@ScottyLightnin Those are good news! thanks for the feedback, I will try to find the issue, at least now we know a workaround.

beto-rodriguez avatar Aug 10 '23 02:08 beto-rodriguez

@ScottyLightnin that is very cool with a workaround. Just to be sure - is it a correct assumption that you use VS for Mac to build and deploy? So no Windows at all in this case. If that is the case I assume you haven't tried the "hybrid" with Windows VS and bridge remote mac.

JerryAndersen avatar Aug 10 '23 08:08 JerryAndersen

@ScottyLightnin that is very cool with a workaround. Just to be sure - is it a correct assumption that you use VS for Mac to build and deploy? So no Windows at all in this case. If that is the case I assume you haven't tried the "hybrid" with Windows VS and bridge remote mac.

Windows VS with Mac remote bridge also works for us. The only failure was deploying direct to local iOS from windows.

ScottyLightnin avatar Aug 10 '23 09:08 ScottyLightnin

I saw this issue with SkiaSharp based libraries multiple times recently, e.g. https://github.com/Mapsui/Mapsui/issues/1872#issuecomment-1573342107

Here is an original SkiaSharp issue about the same problem:
https://github.com/mono/SkiaSharp/issues/2410

Limitation of HotReload:

Static iOS libraries and frameworks aren't supported and you may see runtime errors or crashes if your app attempts to load these.

see https://learn.microsoft.com/en-us/dotnet/maui/ios/hot-restart#limitations

Solution: Do not directly connect your iOS devices to your Windows dev machine but use a Mac remote bridge...

erdmenchen avatar Aug 10 '23 10:08 erdmenchen

I saw this issue with SkiaSharp based libraries multiple times recently, e.g. Mapsui/Mapsui#1872 (comment)

Here is an original SkiaSharp issue about the same problem: mono/SkiaSharp#2410

Limitation of HotReload:

Static iOS libraries and frameworks aren't supported and you may see runtime errors or crashes if your app attempts to load these.

see https://learn.microsoft.com/en-us/dotnet/maui/ios/hot-restart#limitations

Solution: Do not directly connect your iOS devices to your Windows dev machine but use a Mac remote bridge...

Is this mean it will work when we publish it?

sencagri avatar Aug 18 '23 12:08 sencagri