Getting infinite console messages when adding items to an ObservableCollection that is tied to a ListView
Should not do this
Dumps bunchs of log messages like this:
06-27 17:04:14.986 W/View (19973): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{47ded6c V.ED..... ......ID 0,0-917,65 #2d} during layout: running second layout pass
06-27 17:04:14.986 W/View (19973): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{c1232c7 V.ED..... ......ID 0,0-917,65 #30} during layout: running second layout pass
06-27 17:04:15.003 W/View (19973): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{d1bbe45 V.ED..... ........ 0,0-917,65 #31} during second layout pass: posting in next frame
06-27 17:04:15.003 W/View (19973): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{47ded6c V.ED..... ........ 0,0-917,65 #2d} during second layout pass: posting in next frame
This started happening after I upgraded XF from 2.5.0.1222 to 3.1.0.583944. It did not happen on the previous version.
I have tested on Android Emulator running API 27 and on a physical device running Android 7.1.1
Additional piece of info. Tried with XF version 3.0.0.561731 and the issue does not occur. So its something introduced in XF 3.1
This also happened to me while using XF 3.2. I added:
<Label FormattedText="{Binding TimeAndLocation}" />
and it just started outputting as reported, and the app behaves very laggy because of the many print outs.
09-24 14:04:22.313 W/View (17691): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{5e7ba2b V.ED..... ......ID 0,0-780,49 #a4} during layout: running second layout pass
09-24 14:04:22.313 W/View (17691): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{8a74f83 V.ED..... ......ID 0,0-780,49 #ab} during layout: running second layout pass
09-24 14:04:22.349 W/View (17691): requestLayout() improperly called by md58432a647068b097f9637064b8985a5e0.NavigationPageRenderer{e666328 V.E...... ........ 0,0-1080,1704 #7} during second layout pass: posting in next frame
09-24 14:04:22.349 W/View (17691): requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.FormsTextView{a5443db V.ED..... ........ 0,0-780,49 #b2} during second layout pass: posting in next frame
Just had it again...
Changed
..to..
..and it started printing out the errors.
Is within a ViewCell in a ListView.
XF 3.4
Just wanted to see if there was any movement on this. While it was annoying on iOS, later iPhone models would mask the problem because of their performance specs.
However, on Android, it's ridiculously laggy, even on a OnePlus 6, which is only a year old. It literally makes the app unusable.
I am writing an instagram type app, which makes use of user mentions and hashtags, so I need the FormattedText to work. I can't just use Text
.
I'm also getting these logs:
[View] requestLayout() improperly called by md5f92e0daf340890c9667469657ee2ece8.LabelRenderer{ec466b7 V.ED..... ......ID 0,24-280,94 #e1} during layout: running second layout pass
[View] requestLayout() improperly called by md5fe8996628db2722b2645843f91097c26.CachedImageFastRenderer{9c85cde V.ED..... ......ID 20,24-380,384 #de} during layout: running second layout pass
[View] requestLayout() improperly called by md5f92e0daf340890c9667469657ee2ece8.LabelRenderer{236fcd8 V.ED..... ......ID 0,0-884,90 #e6} during layout: running second layout pass
[View] requestLayout() improperly called by md5fe8996628db2722b2645843f91097c26.CachedImageFastRenderer{b12edec V.ED..... ......ID 20,24-380,384 #e5} during layout: running second layout pass
[View] requestLayout() improperly called by md5f92e0daf340890c9667469657ee2ece8.LabelRenderer{6b3a79b V.ED..... ......ID 0,0-884,90 #ed} during layout: running second layout pass
[View] requestLayout() improperly called by md5fe8996628db2722b2645843f91097c26.CachedImageFastRenderer{961627f V.ED..... ......ID 20,24-380,384 #ec} during layout: running second layout pass
[View] requestLayout() improperly called by md5f92e0daf340890c9667469657ee2ece8.LabelRenderer{afab0a V.ED..... ......ID 0,0-884,90 #f4} during layout: running second layout pass
[View] requestLayout() improperly called by md5fe8996628db2722b2645843f91097c26.CachedImageFastRenderer{208bcfe V.ED..... ......ID 20,24-380,384 #f3} during layout: running second layout pass
[View] requestLayout() improperly called by md5f92e0daf340890c9667469657ee2ece8.LabelRenderer{b90ac55 V.ED..... ......ID 0,0-884,90 #fb} during layout: running second layout pass
[View] requestLayout() improperly called by md5f92e0daf340890c9667469657ee2ece8.LabelRenderer{8108f36 V.ED..... ......ID 0,24-280,94 #fd} during layout: running second layout pass
[View] requestLayout() improperly called by md5fe8996628db2722b2645843f91097c26.CachedImageFastRenderer{59daf99 V.ED..... ......ID 20,24
This is with the latest xamarin.forms version, target v9.0 Android, and latest support libraries.
I worked around the issue by setting my Listview caching strategy to RetainElement. This made all the requestLayout messages go away. So it seems related to RecycleElement. Has that worked for anyone else?
@vbisbest So that "works" for me, as I get all of the requestLayout messages to go away and performance is way better.
However, now there are small hitches when scrolling, which is something I was seeing on iOS.
So it definitely helps, but there are still performance issues when scrolling, just not as bad.
@bcaceiro I have seen this error for my ButtonRenderer when I was trying to update the button padding after calling base.OnLayout. This makes 100s of requestLayout message per sec. The approach I used was to set the padding before calling base.OnLayout.
I worked around the issue by
Changed
private FormattedString _formattedChat;
public FormattedString FormattedChat
{
get => _formattedChat;
set => SetProperty(ref _formattedChat, value);
}
var tempFormattedChat = new FormattedString();
tempFormattedChat.Spans.Add(new Span
{
Text = "test",
FontSize = 14,
});
FormattedChat = tempFormattedChat;
..to..
public FormattedString FormattedChat
{
get {
var tempFormattedChat = new FormattedString();
tempFormattedChat.Spans.Add(new Span
{
Text = "test",
FontSize = 14,
});
return tempFormattedChat;
}
}
Setting 'retain element' is solving this problem by creating another. It is not recommended.
DuongQuocNghi solution is right. The problem here is that every FormattedString and even every span instances are "Single use".
Everytime your cell is drawn - OnBindingContextChanged is called.
And this FormattedLabel has some specific behavior(i guess its a bug) that you must return new Instance of FormattedString in ViewModel every time. You can't even reuse Spans instances. You must create new Spans inside new FormattedString everytime your getter is called.
Getting this a lot in XF4.4.0.991640. I have a complex page with a bindable stacklayout, which in turn contains items which have bindable stacklayouts (within Syncfusion expanders) and it makes rendering on an Android device very slow. It also seems to effect the Syncfusion expander which sometimes will not properly expand for it's content. It seems to work find on iOS, although i haven't yet checked if the same lines are logged on iOS.
I won't pretend to understand whats going on with this particular issue but I also found it occurs when using the SyncFusion text editor controls inside a ListView data template for an observable collection as whence are made to item properties in the collection.
I'm getting a similar problem on XF 4.5.0.530, when using a searchBar to filter the results of a ListView. When I type something into the searchBar, the following comes up in my output window:
04-09 13:52:21.299 W/View ( 3256): requestLayout() improperly called by crc643f46942d9dd1fff9.ScrollViewContainer{406f3ca V.E.HV... ......ID 0,0-970,2028} during layout: running second layout pass
04-09 13:52:21.312 W/View ( 3256): requestLayout() improperly called by crc64720bb2db43a66fe9.NavigationPageRenderer{4caf147 V.E...... .......D 0,0-1080,1962 #13} during second layout pass: posting in next frame
info: System.Net.Http.HttpClient.ApiClient.LogicalHandler[100]
From what I can see, it has something to do with ListViews not resizing when the searchBar updates its contents, which are set by an ObservableCollection. Does anyone have a workaround for this?
Is there any type of work around for this?
I have a very simple contentpage with only an sfexpander and I'm getting alot of these:
requestLayout() improperly called by android.widget.TextView
requestLayout() improperly called by crc64ee486da937c010f4.LabelRenderer
Guys, if you have this problem using some syncfusion stuff then report this to syncfusion. This issue is about this error getting triggered by Label.FormattedText
This issue doesn't seem to have had any activity in a long time. We're working on prioritizing issues and resolving them as quickly as we can. To help us get through the list, we would appreciate an update from you to let us know if this is still affecting you on the latest version of Xamarin.Forms, since it's possible that we may have resolved this as part of another related or duplicate issue. If we don't see any new activity on this issue in the next 30 days, we'll evaluate whether this issue should be closed. Thank you!
This is an ongoing issue with syncfusion's expander component. Here's the latest thread tracking their upcoming fix.
https://www.syncfusion.com/forums/150648/sfexpander-example
Still occurring for me on that same screen. I've switched from the Syncfusion expander to the Xamarin Forms expander, and still the same type of lines are output:
11-04 10:05:43.740 W/View (10990): requestLayout() improperly called by crc64ee486da937c010f4.LabelRenderer{c565e97 V.ED..... ......ID 0,0-187,66 #c5} during layout: running second layout pass
11-04 10:08:55.784 W/View (10990): requestLayout() improperly called by crc64ee486da937c010f4.LabelRenderer{e62b2fd V.ED..... ......ID 0,0-65,49 #41a} during layout: running second layout pass
However that said, it doesn't seem to be as bad as i remember, and maybe a little less consistent perhaps as not every expand/collapse action will create those lines. But there are definitely times where you open one and it pops up a dozen or so of the above.
Most helpful comment
This also happened to me while using XF 3.2. I added:
<Label FormattedText="{Binding TimeAndLocation}" />
and it just started outputting as reported, and the app behaves very laggy because of the many print outs.