Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Crash XF for Mac 4.7.0.1080 #11272

Closed
JohnHDev opened this issue Jul 1, 2020 · 2 comments
Closed

[Bug] Crash XF for Mac 4.7.0.1080 #11272

JohnHDev opened this issue Jul 1, 2020 · 2 comments
Assignees
Labels
4.7.0 regression on 4.7.0 a/label e/2 🕑 2 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression in-progress This issue has an associated pull request that may resolve it! p/macOS t/bug 🐛
Projects

Comments

@JohnHDev
Copy link

JohnHDev commented Jul 1, 2020

Description

Just updated from XF 4.5.0.657 to 4.7.0.1080.
App now crashes when attempting to render labels that contains formatted strings which are made up of several spans containing emoji's as well as text. The labels are also contained in grids.

The issue was introduced as early as 4.6, but Im not going to restore each version manually just to check.

Steps to Reproduce

Callstack:
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_out_nfloat_out_nfloat_out_nfloat_out_nfloat(intptr,intptr,System.nfloat&,System.nfloat&,System.nfloat&,System.nfloat&)
at AppKit.NSColor.GetRgba (System.nfloat& red, System.nfloat& green, System.nfloat& blue, System.nfloat& alpha) [0x0000c] in /Library/Frameworks/Xamarin.Mac.framework/Versions/6.18.2.1/src/Xamarin.Mac/NSColor.g.cs:944
at Xamarin.Forms.Platform.MacOS.ColorExtensions.ToColor (AppKit.NSColor color) [0x00015] in <80383802214540fe948b297f6790b923>:0
at Xamarin.Forms.Platform.MacOS.FormattedStringExtensions.ToAttributed (Xamarin.Forms.Span span, Xamarin.Forms.BindableObject owner, Xamarin.Forms.Color defaultForegroundColor, Xamarin.Forms.TextAlignment textAlignment, System.Double lineHeight) [0x000c0] in <80383802214540fe948b297f6790b923>:0
at Xamarin.Forms.Platform.MacOS.FormattedStringExtensions.ToAttributed (Xamarin.Forms.FormattedString formattedString, Xamarin.Forms.BindableObject owner, Xamarin.Forms.Color defaultForegroundColor, Xamarin.Forms.TextAlignment textAlignment, System.Double lineHeight) [0x0001b] in <80383802214540fe948b297f6790b923>:0
at Xamarin.Forms.Platform.MacOS.LabelRenderer.UpdateFormattedText () [0x00033] in <80383802214540fe948b297f6790b923>:0
at Xamarin.Forms.Platform.MacOS.LabelRenderer.UpdateTextPlainText () [0x0004d] in <80383802214540fe948b297f6790b923>:0
at Xamarin.Forms.Platform.MacOS.LabelRenderer.UpdateText () [0x0001e] in <80383802214540fe948b297f6790b923>:0
at Xamarin.Forms.Platform.MacOS.LabelRenderer.OnElementChanged (Xamarin.Forms.Platform.MacOS.ElementChangedEventArgs`1[TElement] e) [0x0008c] in <80383802214540fe948b297f6790b923>:0

Expected Behavior

Not to crash.

Actual Behavior

Crash with the above call stack.

Basic Information

  • Version with issue:
  • Last known good version: XF 4.5.0.657
  • IDE:
  • Platform Target Frameworks:
    • iOS:
    • Android:
    • UWP:
  • Android Support Library Version:
  • Nuget Packages:
  • Affected Devices:

Screenshots

Reproduction Link

Workaround

Setting the label TextColor appears to work as a hackaround/workaround.

@JohnHDev JohnHDev added s/unverified New report that has yet to be verified t/bug 🐛 labels Jul 1, 2020
@pauldipietro pauldipietro added this to New in Triage Jul 1, 2020
@samhouts samhouts added 4.7.0 regression on 4.7.0 a/label i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression p/macOS labels Jul 1, 2020
@samhouts
Copy link
Member

samhouts commented Jul 1, 2020

Can you please attach a small project that demonstrates this issue? Thanks!

@samhouts samhouts added s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jul 1, 2020
@JohnHDev
Copy link
Author

JohnHDev commented Jul 2, 2020

@samhouts I thought you might ask me for that. :)

If you haven't already, create a Mac app and add XF to it as per: https://devblogs.microsoft.com/xamarin/preview-bringing-macos-to-xamarin-forms/

Delete the main page and replace it with the following (and update the namespace accordingly):

`
using System;
using Xamarin.Forms;

namespace XF4iOSAndroidMacDemo
{
public class MainPage: ContentPage
{
// NSInvalidArgumentException: *** -getRed:green:blue:alpha: not valid for the NSColor Generic Gray Gamma 2.2 Profile colorspace 0 1; need to first convert colorspace.

    public MainPage()
    {
        Content = new StackLayout
        {
            Children =
            {
                new Label()
                {
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    //TextColor = Color.Black,
                    FormattedText = new FormattedString
                    {
                        Spans =
                        {
                            new Span()
                            {
                                Text = "🔔🌀 Welcome to Xamarin.Forms!",
                            },
                        }
                    }
                }
            }
        };
    }
}

}
`

Ensure that the XF nuget is 4.7+ for the solution. I was using 4.7.0.1080.
Set the Mac project to be startup in the solution.
Run it. You should see an exception thrown: NSInvalidArgumentException: *** -getRed:green:blue:alpha: not valid for the NSColor Generic Gray Gamma 2.2 Profile colorspace 0 1; need to first convert colorspace.

Remove the TextColor commented out line.
Clean the solution (VS4Mac bug, need to clean before every build).
Run again, no crash.

@samhouts samhouts moved this from New to Needs Info in Triage Jul 2, 2020
@samhouts samhouts removed s/needs-info ❓ A question has been asked that requires an answer before work can continue on this issue. s/needs-repro ❔ This reported issue doesn't include a sample project reproducing the issue. Please provide one. labels Jul 2, 2020
@samhouts samhouts moved this from Needs Info to New in Triage Jul 2, 2020
@jsuarezruiz jsuarezruiz self-assigned this Jul 3, 2020
@jsuarezruiz jsuarezruiz moved this from New to Ready For Work in Triage Jul 3, 2020
@jsuarezruiz jsuarezruiz removed the s/unverified New report that has yet to be verified label Jul 3, 2020
@samhouts samhouts added the in-progress This issue has an associated pull request that may resolve it! label Jul 3, 2020
@samhouts samhouts added this to In Progress in 4.7.0 Jul 3, 2020
Triage automation moved this from Ready For Work to Closed Jul 3, 2020
4.7.0 automation moved this from In Progress to Done Jul 3, 2020
@samhouts samhouts removed this from Closed in Triage Aug 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
4.7.0 regression on 4.7.0 a/label e/2 🕑 2 i/high Completely doesn't work, crashes, or is unusably slow, has no obvious workaround; occurs less often i/regression in-progress This issue has an associated pull request that may resolve it! p/macOS t/bug 🐛
Projects
No open projects
4.7.0
  
Done
Development

No branches or pull requests

3 participants