Fix NullReference in SkiaSharp WPF renderer if UIElement has no Prese…#1799
Fix NullReference in SkiaSharp WPF renderer if UIElement has no Prese…#1799VisualMelon merged 1 commit intooxyplot:developfrom
Conversation
|
Thanks for putting this together. I can't take a proper look now, but hopefully I'll be able to get back to you on this in the next few days. |
|
I force pushed a version with the fix (default values if the ancestor visual is null) for the canvas renderer, too. |
|
Another NullReferenceException appeared during tests of our application with the latest Oxyplot version. Hopefully you @VisualMelon or another maintainer will have time to review it soon. |
|
Merged now so that we can look at #1820 properly, and because this was checked with the WPF and has 3 issues requesting the fix. Thanks again @albtaeler for this and #1797 |
| protected override double UpdateDpi() | ||
| { | ||
| var scale = base.UpdateDpi(); | ||
| this.RenderContext.DpiScale = scale; |
There was a problem hiding this comment.
Was this really planned? Slightly inconsistent with the rest of the PR and its description.
P.S. I periodically push new changes to my fork - https://github.com/HavenDV/H.OxyPlot
There was a problem hiding this comment.
Thanks for spotting this.
For Skia/WPF it's fine I believe as it's handled at a different level, but does look like a regression for non-Skia/WPF which is a bit hard to spot, but the most obvious thing is that axis lines are fuzzy when the scale isn't 1.
@albtaeler do you recall if there was a particular reason for removing this, or did it just look redundant?
There was a problem hiding this comment.
I can't remember a specific reason. Maybe it was a merge accident, or for redundantency reasons. But I think you're right, it's still needed for the non-Skia/WPF renderer.
There was a problem hiding this comment.
@albtaeler thanks for taking another look; feel free to open a PR putting this back in; hopefully I'll get around to it eventually otherwise.
| /// </summary> | ||
| protected void Render() | ||
| { | ||
| if (this.plotPresenter == null || this.renderContext == null || !(this.isInVisualTree = this.IsInVisualTree())) |
There was a problem hiding this comment.
This raises questions too - it cannot throw a NullReferenceException. If it's just a refactoring - then the behavior is changed.
There was a problem hiding this comment.
This was mentioned in #1798 (comment) but looking briefly now it does look a bit odd.
I'll try to find time to take another look at this (I should have some tests lying around somewhere....); my WPF knowledge is pretty limited, so I'd welcome any input from you and @albtaeler.
There was a problem hiding this comment.
Didn't see the comment. Considering it, it's all right. The only question is - did this check play any role in performance?
There was a problem hiding this comment.
I believe the only reason for this check was that this.TransformToAncestor() fails with a NullReferenceException without my changes. As mentioned in #1798 (comment) I changed this behavior, because rendering it's not possible if it isn't in the VisualTree, but sometimes needed.
I could not see any performance changes. It is important that the property this.isInVisualTree = this.IsInVisualTree(); is set.
There was a problem hiding this comment.
I was confused at this point only because I don't see a place where IsInVisualTree() could throw a NullReferenceException.
…ntationSource (#1798)
Fixes #1798 .
Checklist
Changes proposed in this pull request:
@oxyplot/admins