Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MAUI basic sample only display when navigated using Shell for both Android and iOS. Normal navigation does not render #481

Closed
hbraasch opened this issue May 19, 2022 · 14 comments
Labels
bug Something isn't working maui priority unknown An external issue where we cannot do much about it. requires external features We can not fix this for now, we need a feature that is out of this library.

Comments

@hbraasch
Copy link

hbraasch commented May 19, 2022

Describe the bug
Initially:
MAUI basic sample crashes for both Android and iOS with[LiveChartsCore.SkiaSharpView.Maui.MotionCanvas is incompatible].
Sample app is a simple CartesianChart based on MAUI install example
Finally: Realized it has to do with [Shell] or normal navigation (see later discussion).

To Reproduce
Steps to reproduce the behavior:

  1. Go to github repository for sample project: https://github.com/hbraasch/LiveChartsMauiSample.git
  2. Clone project and run for both Android and iOS
  3. Observe exception

Expected behavior
Line chart should display

Screenshots
image

Smartphone (please complete the following information):

  • Device: Latest emulators for IOS and Android
  • MAUI RC3
@beto-rodriguez
Copy link
Owner

Hi!

Thanks for the report, did you try .UseSkiaSharp(true) ?

https://lvcharts.com/docs/Maui/2.0.0-beta.220/Overview.Installation

This will be moved before the Create a View Model section to clarify

@hbraasch
Copy link
Author

Yes, its in there. Unfortunately.
Must be a different problem. Have found a lot of regression problems with MAUI RC. Could be the issue resolves itself 😊
Regards.

@beto-rodriguez beto-rodriguez added the not verified It is probably an issue, but we have not enough evidence to mark this as a bug. label May 19, 2022
@hbraasch
Copy link
Author

Hi

My sincere apologies! I forgot to add [.UseSkiaSharp(true)] in the repro project. It now works with the chart defined in XAML.

However (as it started for me), I prefer defining my GUIs using code-behind, and the code I created to embed a graph does not render.
Here is the code example, it is also in the updated repro on Github

internal class CodeBehindMainPage : ContentPage
    {
        public CodeBehindMainPage()
        {
            var chart = new CartesianChart();
            chart.Series = new ISeries[]
            {
                new LineSeries<double>
                {
                    Values = new double[] { 2, 1, 3, 5, 3, 4, 6 },
                    Fill = null
                }
            };
            var grid = new Grid();
            grid.Add(chart);
            Content = grid;
        }
    }

Any idea what I'm doing wrong?

Thanks and regards

@beto-rodriguez
Copy link
Owner

beto-rodriguez commented May 19, 2022

I forgot to add [.UseSkiaSharp(true)]

Glad to hear that, so the control is working!

I think that you second question is not related with the library, try to add another control first, like a button or something from MAUI, then see if it renders, if it does but the chart does not then the issue is from this library.

Something that helps me is to set a background color to the grid, then you can see if the grid has a valid size, some times depending on the container it does not renders as we think it would,

@hbraasch
Copy link
Author

I've now noticed that if I navigate to the code-behind page using [Shell], it renders.
But if I navigate to it using my regular approach (which works if I replace the graph with a label), it renders fine.
Regular approach:

MainPage = new NavigationPage(new CodeBehindMainPage());

Any ideas maybe?

@beto-rodriguez
Copy link
Owner

beto-rodriguez commented May 19, 2022

Not completely sure.

Being honest, I think that that kind of issues have a low chance to be an issue in this library, it could be an issue with SkiaSharp or MAUI.

but feel free to re-open this issue if you think that this issue is related with this library.

@hbraasch
Copy link
Author

Thanks for looking at this.
I'll generate a repro project and raise it as a issue under MAUI and see how they react.
Regards

@hbraasch
Copy link
Author

Issue raised at MAUI: dotnet/maui#7350

@hbraasch hbraasch changed the title MAUI basic sample crashes for both Android and iOS with [Maui.MotionCanvas is incompatible] MAUI basic sample only display when navigated using Shell for both Android and iOS. Normal navigation does not render May 19, 2022
@hbraasch
Copy link
Author

I've now discovered the chart does not display while running under the debugger. If running outside the debugger, all works fine.

Any possibility there is a [if (Debugger.IsAttached)... somewhere inside your code?

@beto-rodriguez
Copy link
Owner

beto-rodriguez commented May 20, 2022

Thanks for the Research, it seems that the error is here in LiveCharts, I tested your repo and added a view containing a SKCanvasView (from skia sharp) and it works 🤔

Any possibility there is a [if (Debugger.IsAttached)... somewhere inside your code?

Not as far as I remember... need to find what is wrong here

@beto-rodriguez beto-rodriguez added bug Something isn't working and removed not verified It is probably an issue, but we have not enough evidence to mark this as a bug. labels May 20, 2022
@hbraasch
Copy link
Author

Hope you find it. Its a great library!

@beto-rodriguez beto-rodriguez added the requires external features We can not fix this for now, we need a feature that is out of this library. label Jun 5, 2022
@beto-rodriguez
Copy link
Owner

This seems a Maui issue, I added information to the issue you opened in Maui, lets wait for them to fix that, if they do not, then we could build a workaround.

@hbraasch
Copy link
Author

hbraasch commented Jun 5, 2022

Great, Thanks

@beto-rodriguez beto-rodriguez added the priority unknown An external issue where we cannot do much about it. label Mar 2, 2023
@beto-rodriguez
Copy link
Owner

Since beta.860 we removed the support for the XAML preview in MAUI, so this should be already working. Thanks for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maui priority unknown An external issue where we cannot do much about it. requires external features We can not fix this for now, we need a feature that is out of this library.
Projects
None yet
Development

No branches or pull requests

2 participants