Bug 59595 - Error with SearchBar inside of a Grid with iOS 11 SDK
Summary: Error with SearchBar inside of a Grid with iOS 11 SDK
Status: RESOLVED FIXED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.4.0
Hardware: PC Mac OS
: Normal major
Target Milestone: ---
Assignee: Rui Marinho
URL:
Depends on:
Blocks:
 
Reported: 2017-09-20 03:00 UTC by Brian Macomber
Modified: 2018-01-24 10:01 UTC (History)
12 users (show)

Tags: searchbar, grid, ios 11, ac, fr
Is this bug a regression?: ---
Last known good build:


Attachments
Reproduction (31.87 KB, application/zip)
2017-09-20 03:23 UTC, Paul DiPietro [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Brian Macomber 2017-09-20 03:00:39 UTC
<ContentView xmlns="http://xamarin.com/schemas/2014/forms" 
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:ui="clr-namespace:AS.Mobile.Common.UI;assembly=AS.Mobile.Common"
             x:Class="AS.Mobile.DealerTools.Clients.Controls.ClientListSearchControl">
    <StackLayout Orientation="Vertical">
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"></ColumnDefinition>
                <ColumnDefinition Width="*"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="20"></RowDefinition>
            </Grid.RowDefinitions>
            <SearchBar Grid.Column="0" Placeholder="Client Name" Text="{Binding Clients.SearchFilter, Mode=TwoWay}"
                             SearchCommand="{Binding Clients.CommandSearch}">
            </SearchBar>
            <SearchBar Grid.Column="1" Placeholder="Dealer Name" Text="{Binding DealerSearchFilter, Mode=TwoWay}"
                             SearchCommand="{Binding Clients.CommandSearch}" IsVisible="{Binding ShowDealerSearch}">
            </SearchBar>
        </Grid>
        <StackLayout Orientation="Horizontal" IsVisible="{Binding SessionIsManager}">
            <Label Text="Only My Clients" VerticalOptions="Center" Style="{StaticResource LabelSmallBold}"></Label>
            <Switch IsToggled="{Binding OnlyMyClients, Mode=TwoWay}" VerticalOptions="Center"></Switch>
        </StackLayout>
    </StackLayout>
</ContentView>

Produces the following error after updates for iOS 11

Unhandled Exception:

Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInternalInconsistencyException Reason: -[UISearchBar sizeThatFits:] does not support passing non-finite values ({inf, 56})
Native stack trace:
	0   CoreFoundation                      0x00000001146231cb __exceptionPreprocess + 171
	1   libobjc.A.dylib                     0x0000000115420f41 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000114628362 +[NSException raise:format:arguments:] + 98
	3   Foundation                          0x000000010a3d2089 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
	4   UIKit                               0x0000000107f1402b -[UISearchBar sizeThatFits:] + 347
	5   AS.Mobile.DealerTools.iOS           0x0000000105fe0369 xamarin_dyn_objc_msgSend + 217
	6   ???                                 0x0000000134dc7060 0x0 + 5181829216
	7   ???                                 0x0000000135a51d22 0x0 + 5194980642
Comment 1 Brian Macomber 2017-09-20 03:01:42 UTC
Additional Note, if you comment out the SearchBars it doesn't error
Comment 2 Brian Macomber 2017-09-20 03:19:34 UTC
Appears to be related to columns with * widths, setting them to a fixed amount works
Comment 3 Paul DiPietro [MSFT] 2017-09-20 03:23:01 UTC
Created attachment 24825 [details]
Reproduction
Comment 4 Brian Macomber 2017-09-20 03:34:00 UTC
Setting a starting WidthRequest on the search bar appears to be a work around.
Comment 5 Chase Florell 2017-09-22 04:14:07 UTC
This also happens on a SearchBar inside an AbsoluteLayout 

<SearchBar AbsoluteLayout.LayoutBounds="0,0,1,-1" AbsoluteLayout.LayoutFlags="WidthProportional" />
Comment 6 Damir Beylkhanov 2017-09-25 13:32:38 UTC
I've resolved this issue y replacing <Grid> on <StackLayout>, cuz, any tryings to set widths/heights values for grid columns/rows were unsuccessful
Comment 7 Damir Beylkhanov 2017-09-25 15:07:39 UTC
or you can set widthrequest for searchbar to 1 without any other changes in XAML
Comment 8 Brian Macomber 2017-09-25 15:26:18 UTC
I would guess that iOS 11 SDK requires an actual value for width and height, while previous SDKS allowed the "inf" which I assume is infinite.  The renderer likely needs to be updated to supply a different default value when instantiating the iOS search control, prior to the layout being calculated.

I'm just not sure what other side affects that would have, for me I just set the request width to 10 knowing that the layout will change that before display.  I just don't know what other side affects that might cause in other cases.
Comment 10 Rui Marinho 2017-10-19 10:14:02 UTC
Should be fixed on 2.5.0-pre2
Comment 11 Govardhan N 2018-01-24 10:01:40 UTC
I am facing same issue with "Search Bar" for iOS 11.2 SDK, after updating Xamarin.forms to version="2.5.0.122203"

If width is specified to search bar, then it works fine. But if we don't specify width then "NSInternalInconsistencyException Reason: -[UISearchBar sizeThatFits:] does not support passing non-finite values" error occurs.

Is this issue fixed or still open?