Open holecekp opened 4 years ago
Microsoft Partner Center reports 6 hits in the last 72 hours in its Health Reporrts :-(. I have not been able to reproduce this bug on computer with Visual Studio, but I have reproduced it on a laptop. I have been using the app for about 2 minutes and, suddenly, it crashed.
This formatted string can consists of a few parts that have different colors (however, in this case, the FormattedString had only a single Span).
@holecekp Are you able to tell us anything more specific about the values in the formatted string? If we knew more about the content (including the span and the colors), that might help us track this down.
The method with the crash, FindDefaultLineHeight, is very weird. The UpdateText method in the renderer is using it to measure all of the heights of the spans, but it's doing so by iterating over the spans and, for each one,
After which the renderer immediately adds the run back to the TextBlock.
This seems really awkward and inefficient, unless I'm missing something. I'd need to dive deeper, but it sort of looks like RecalculateSpanPositions (which uses the list of heights gathered from this method) will size middle lines incorrectly if later spans are shorter than earlier spans.
@hartez The application is a Morse code translator. The text has generally multiple lines. The content is provided by the user. It can be either a normal text, or a Morse code (characters ".", "-", "/", spaces and newlines).
The application can transmit the entered text as a Morse code using the speakers. The purpose of the formatted text is to show the current position what has already been transmitted:
The last possible situation is when the user did not enter any text yet (or when it was cleared) - a FormattedText without any spans is set.
I have looked at the stack trace and the crash happened in a function that cannot be called when the transmission is on. So when it crashed, there must have been only a single span with the whole text in the FormattedString, or a FormattedString without any spans.
Update:
I have tried to reproduce the issue notifying the change of TextColor etc. every short time. But I have not managed to reproduce the issue :(
However, in FindDefaultLineHeight
we basically do what E.Z has already commented, we add a line, Measure it to obtain the size, eliminated the line and return the height. Although I have not managed to reproduce, I think we can accept the issue and find a more efficient way to get the line size.
Hay do you think @hartez?
I also suggest using the release mode and run the app in x64 mode when trying to reproduce it. My experience is that these two settings makes various bugs on UWP much more likely to appear in general.
By the way, the bug is also in 5.0.0 pre 3. I have reproduced the issue also in that version accidentally while I was trying to reproduce another issue.
The application was in the foreground but I was not using the computer for about 3 minutes (it seems that this period of inactivity increases the chance for reproducing this issue). Then I quickly clicked several times on a button that updates an Editor text and an Label with FormattedText (single Span without color settings). The application crashed.
Description
AppCenter reports the following a crash of my application on UWP:
ComCallHelpers.Call (__ComObject, RuntimeTypeHandle, Int32, Size) System.Exception: Unspecified error (Exception from HRESULT: 0x80004005)
Stack Trace:
I have a label which has FormattedString as its content. This formatted string can consists of a few parts that have different colors (however, in this case, the FormattedString had only a single Span). From the end of the stack trace: the view model updated a property that has type of FormattedString and that is data-bound to a Label. The view model then executed PropertyChanged to notify about this change. After that, LabelRenderer in Xamarin.Forms crashed the application.
Unfortunately, this will be one of many Xamarin.Forms bugs on UWP that either happen randomly, or are connected only to some computer configurations. I do excessive testing and I have never encountered this crash on my computer. Providing a repro solution will be almost impossible. Still, I think that even these bugs, which are very hard to reproduce, should not be ignored if they lead to crashes. I hope that the stack trace from AppCenter will be helpful.
Steps to Reproduce
Expected Behavior
No crashes.
Actual Behavior
Application crashes.
Basic Information
Workaround
No workaround