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

Plot doesn't display until Window resize on Xamarin.Forms UWP #34

Open
clarkis117 opened this issue Sep 25, 2016 · 16 comments
Open

Plot doesn't display until Window resize on Xamarin.Forms UWP #34

clarkis117 opened this issue Sep 25, 2016 · 16 comments

Comments

@clarkis117
Copy link

A possible bug with the Oxyplot for Windows UWP , PlotView interacting with the Xamarin.Forms View Renderer. The plot doesn't display until after the window resizes. After the window resizes the UWP canvas draws the plot.

@objorke
Copy link
Member

objorke commented Oct 11, 2016

I have updated the Xamarin.Forms/SimpleDemo example for UWP, and see the same error there.

@objorke objorke added this to the v1.0 milestone Oct 11, 2016
@objorke objorke added the UWP label Oct 11, 2016
@clarkis117
Copy link
Author

@objorke okay I've been able to pin this bug down to a single point. It's actually in the Oxyplot.Windows project in the implementation of Windows.UI.Xaml.Controls.Control class for PlotView. More specifically, it is in the method override for ArrangedOverride(Size finalSize). The bug being that in a Xamarin Forms UWP project UpdateVisuals() is not being called until the Window is resized; whereas, in a Windows (non-Xamarin.Forms project) it is being called without the Window needing resized.

https://github.com/oxyplot/oxyplot/blob/master/Source/OxyPlot.Windows/PlotView.cs#L799

@clarkis117
Copy link
Author

From PR: I thinking one of the main problems is that the size parameter is only provided to the protected override Size ArrangeOverride(Size finalSize) method once, and in all my debugging it's only been 0 for both x and y thus causing UpdateVisuals() to not be called.

@clarkis117
Copy link
Author

clarkis117 commented Nov 4, 2016

@objorke It seems that in the Windows PlotView, when being invoked by the Xamarin.Forms Renderer, PlotView.ActualHeight and PlotView.ActualWidth are not set before the first arrange pass.

@objorke objorke modified the milestones: v2.0, v1.0 Jan 7, 2017
@objorke
Copy link
Member

objorke commented Jan 8, 2017

This should be solved in OxyPlot.Xamarin.Forms.1.1.0-unstable0011 (nuget.org)

@objorke
Copy link
Member

objorke commented Jan 8, 2017

@clarkis117 can we close this issue?

@objorke objorke self-assigned this Jan 8, 2017
@dimitrijevic
Copy link
Contributor

dimitrijevic commented Jan 27, 2017

@clarkis117 I personally haven't had trouble with pie charts showing up in debug mode upon loading, resizing or not...but I've tried to build my UWP app in release mode and unfortunately I'm still not getting it to show up although it shows the pie chart just fine in debug (with 1.1.0-unstable0011 too)...if anyone was able to build it in release and then show up could you share any runtime directives you used...maybe if you copy those to the library rd.xml it may start working in other people's apps in release too...I've recently been able to solve one UWP app's problem following some advice here (but that app used the AutoMapper/LINQ reflection/serialization)


@objorke I may have spoke too soon...turns out, for me at least, charts showing up, without having to resize anything, was, in fact, just a fluke...because I used Microsoft.NETCore.UniversalWindowsPlatform-prerelease...if you use stable 5.2.0, even in debug it won't show, until you actually resize the window first (so I'd guess that with prerelease in debug this resizing issue is solved for having to resize, but in release and thus being able to publish to Store, it's still problem on even if you use the aforementioned latest prerelease nuget - 5.3.0-beta2) which is a 100% sure sign the .NET Native compiler is to blame and the only way to currently fix it without waiting for another of their versions is to use runtime directives they recommend in the ".NET Native deep dive" blog article series (mentioned in the above issue from fixing AutoMapper).

@objorke objorke removed their assignment Feb 6, 2017
@objorke
Copy link
Member

objorke commented Feb 6, 2017

sorry, I can´t contribute on this issue at the moment!
Is it too early to support XamarinForms/UWP?

@dimitrijevic
Copy link
Contributor

Credits here go to @MattWhilden
Ok, I understood, Xamarin.Forms was faulting...at least according to...doing the following debug steps:

  1. Run the SimpleDemo.UWP which uses Xamarin.Forms OxyPlot in Debug version, and the plot shows up, then run it in Release and it doesn't.
  2. Then switch back to Debug mode, but enable .NET Native, and enable exceptions...
  3. As it turns out the exception that turns up and is seemingly responsible for plot not showing up is the 
    one made by making a call that looks like:

                Assembly.Load(new AssemblyName("clrcompression"));

And then .NET Native just ends up throwing FileNotFound because clrcompression is not a .NET library (it’s a native library). As @MattWhilden pointed out Xamarin guards against other Load failures but not that one. And there's a chance they just might fix it soon. Keep fingers crossed...I like OxyPlot, I get Skia's theirs, but why not have both :)

Hope to hear something soon.

@MattWhilden
Copy link

For those keeping track at home, and like to connect all the dots, there's a very similar looking issue on the Xamarin.Forms Bugzilla: https://bugzilla.xamarin.com/show_bug.cgi?id=52482

I'm working on tracking down some Xamarin folks internally, I'll try to keep y'all updated but definitely feel free to ping me if you think I've disappeared for too long. I don't mind. :-)

@MattWhilden
Copy link

@dimitrijevic
Copy link
Contributor

dimitrijevic commented Mar 1, 2017

But how do you use a workaround on this project...since clrcompression is not a .NET assembly and you don't know from the error which usually follows with missing metadata output for which class in what assembly is being used (so I feel it's to no avail to try this workaround on this particular project for some reason except by trying to guess the classes:)...I've used the workaround though on some other projects that I created but which mostly used some Xamarin.Forms control classes and such things?

@dimitrijevic
Copy link
Contributor

dimitrijevic commented Mar 1, 2017

Because I've just tried about all an every class I could think of for OxyPlot to find in which assembly if fails...since we're loading an OxyPlot.Xamarin.Forms assemblies just adding all the classes bellow used in the SimpleDemo above the line OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer.Init(); should be enough:

  assembliesToInclude.Add(typeof(OxyPlot.PlotModel).GetTypeInfo().Assembly);
  assembliesToInclude.Add(typeof(OxyPlot.PlotController).GetTypeInfo().Assembly);
  assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.PlotView).GetTypeInfo().Assembly);
  assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer).GetTypeInfo().Assembly);

but I still get the same exception, maybe it's just me :(

@dimitrijevic
Copy link
Contributor

dimitrijevic commented Mar 1, 2017

Nevermind, call me blind, I've missed one class somehow:

            assembliesToInclude.Add(typeof(OxyPlot.PlotModel).GetTypeInfo().Assembly);
            assembliesToInclude.Add(typeof(OxyPlot.PlotController).GetTypeInfo().Assembly);
            assembliesToInclude.Add(typeof(OxyPlot.Windows.PlotView).GetTypeInfo().Assembly);
            assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.PlotView).GetTypeInfo().Assembly);
            assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer).GetTypeInfo().Assembly);

Adding all of the above (including OxyPlot.Windows.PlotView beside the OxyPlot.Xamarin.Forms.PlotView) to the assemblies to include shows the SimpleDemo chart in Release for me now (I'm sorry for being a dumbass and thanks again @MattWhilden)...now I'll try and add UWP to my project using some other plot types (although I suspect these five or even three should of been enough - OxyPlot.Core, OxyPlot.Windows and OxyPLot.Xamarin.Forms dlls).

@MattWhilden
Copy link

Fantastic news! I am very happy to hear you are unblocked.

Patterns that cause looser coupling in your program (ex: dependency injection) are great for flexibility but definitely cause us headaches when we're trying to make various engineering trade offs. This is a great example: if we roll all of your code into one big native binary we see decent startup and working set wins that benefit everyone. However, we also break anyone who assumed (completely innocently) that we'd never have a good reason to radically re-layout your code on disk.

We have an open issue on our side to try and hide this particular "irregularity" of .NET Native and I've added this as another instance of it causing issues for folks.

If you see anything else out of place (or just want to send some feedback!), please reach out to us again. We are happy to help

@JimSEOW
Copy link

JimSEOW commented Apr 27, 2017

using the latest OxyPlot.Xamarin.Forms.1.1.0-unstable0011 (nuget.org) when using (Microsoft Practices Unity)

In Debug Mode (NOT in Release Mode):
Following the guide here work for UWP.

OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer.Init();

To get it works in Release Mode.

The following extra codes are necessary:

List<Assembly> assembliesToInclude = new List<Assembly>();

//Now, add in all the assemblies your app uses
assembliesToInclude.Add(typeof(OxyPlot.PlotModel).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.PlotController).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.Windows.PlotView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.PlotView).GetTypeInfo().Assembly);   
 assembliesToInclude.Add(typeof(OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer).GetTypeInfo().Assembly); 
// added most for good measure - workaround says add all classes - but only this one class should sufice

//Also do this for all your other 3rd party libraries

OxyPlot.Xamarin.Forms.Platform.UWP.PlotViewRenderer.Init();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants