Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Searchhandler causes App crash when Text changes on iOS #10547

Closed
borrmann opened this issue Oct 7, 2022 · 2 comments · Fixed by #11927
Closed

Searchhandler causes App crash when Text changes on iOS #10547

borrmann opened this issue Oct 7, 2022 · 2 comments · Fixed by #11927
Assignees
Labels
area-controls-entry Entry area-controls-shell Shell Navigation, Routes, Tabs, Flyout fixed-in-7.0.58 Look for this fix in 7.0.58! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/iOS 🍎 t/bug Something isn't working

Comments

@borrmann
Copy link
Contributor

borrmann commented Oct 7, 2022

Description

I have a custom SearchHandler that inherits from SearchHandler class.

I set it on the page .cs file via DependencyInjection like this;

 public CustomersPage(CustomersViewModel customersViewModel, CustomerSearchHandler searchHandler)
        {
            InitializeComponent();
            _viewModel = customersViewModel;
            this.BindingContext = _viewModel;

            searchHandler.ViewModel = _viewModel;
            searchHandler.SearchBoxVisibility = SearchBoxVisibility.Collapsible;

            Shell.SetSearchHandler(this, searchHandler);
        }

when I type something in the SearchBar on the page, the App crashes on iOS. Works perfectly fine on Android!
Looking at the log output it seems like some default colors are missing.

Steps to Reproduce

  1. Create a custom searchhandler that inherits from SearchHandler
  2. Set the SearchHandler in the constructor of the page's .cs file
  3. Type something in the search on an iOS device (I used an actual device connected to Visual Studio on Windows)

Link to public reproduction project repository

https://github.com/borrmann/MauiAppSearchBarHandler.App

Version with bug

6.0.486 (current)

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 16

Did you find any workaround?

No

Relevant log output

[0:] An error occurred: 'Object reference not set to an instance of an object.'. Callstack: '   at Microsoft.Maui.Platform.ColorExtensions.ToPlatform(Color color)
   at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.SetSearchBarIconColor(UIButton button, Color targetColor, UIColor defaultTintColor)
   at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.UpdateClearIconColor(Color targetColor)
   at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.UpdateCancelButtonColor(UIButton cancelButton)
   at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.OnTextChanged(Object sender, UISearchBarTextChangedEventArgs e)
   at UIKit.UISearchBar._UISearchBarDelegate.TextChanged(UISearchBar searchBar, String searchText)
   at UIKit.UIApplication.Main(String[] args, Type principalClass, Type delegateClass)
   at meitiMaui.Program.Main(String[] args) in [.....] line 15
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)'
The app has been terminated.
@borrmann borrmann added the t/bug Something isn't working label Oct 7, 2022
@borrmann borrmann changed the title Searchhandler causes App crash when Text changes on iOS and Searchhandler causes App crash when Text changes on iOS Oct 7, 2022
@borrmann
Copy link
Contributor Author

borrmann commented Oct 8, 2022

Confirmed using iOS simulator on a Mac:

ObjCRuntime.ObjCException: 'Objective-C exception thrown. Name: System.NullReferenceException Reason: Object reference not set to an instance of an object. (System.NullReferenceException)
at Microsoft.Maui.Platform.ColorExtensions.ToPlatform(Color color)
at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.SetSearchBarIconColor(UIButton button, Color targetColor, UIColor defaultTintColor)
at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.UpdateClearIconColor(Color targetColor)
at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.UpdateCancelButtonColor(UIButton cancelButton)
at Microsoft.Maui.Controls.Platform.Compatibility.SearchHandlerAppearanceTracker.OnTextChanged(Object sender, UISearchBarTextChangedEventArgs e)
at UIKit.UISearchBar._UISearchBarDelegate.TextChanged(UISearchBar searchBar, String searchText)

Native stack trace:
0 CoreFoundation 0x00007fff20420af6 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20177e78 objc_exception_throw + 48
2 libxamarin-dotnet-debug.dylib 0x000000010b4a3ddf xamarin_process_managed_exception + 943
3 meitiMaui 0x0000000100b1f9d1 _ZL30native_to_managed_trampoline_7P11objc_objectP13objc_selectorPP11_MonoMethodS0_S0_j + 689
4 meitiMaui 0x0000000100b9122a -[UIKit_UISearchBar__UISearchBarDelegate searchBar:textDidChange:] + 58
5 UIKitCore 0x00007fff23c44931 -[UISearchBar(UISearchBarStatic) _searchFieldEditingChanged] + 139
6 UIKitCore 0x00007fff246972b2 -[UIApplication sendAction:to:from:forEvent:] + 83
7 UIKitCore 0x00007fff23fc08a0 -[UIControl sendAction:to:forEvent:] + 223
8 UIKitCore 0x00007fff23fc0bc3 -[UIControl _sendActionsForEvents:withEvent:] + 332
9 UIKitCore 0x00007fff249e277f -[UITextField fieldEditorDidChange:] + 202
10 UIKitCore 0x00007fff249c7e63 -[UIFieldEditor textInputDidChange:] + 65
11 UIKitCore 0x00007fff249f300d -[UITextInputController _sendDelegateChangeNotificationsForText:selection:] + 113
12 UIKitCore 0x00007fff249f57da -[UITextInputController _insertText:fromKeyboard:] + 757
13 UIKitCore 0x00007fff249f63f9 -[UITextInputController insertText:] + 333
14 UIKitCore 0x00007fff249cb5a9 -[UIFieldEditor insertFilteredText:] + 836
15 UIKitCore 0x00007fff249e8744 -[UITextField insertFilteredText:] + 93
16 UIKitCore 0x00007fff23c4f0c0 -[UISearchTextField insertFilteredText:] + 80
17 UIKitCore 0x00007fff24473291 -[UIKeyboardImpl insertText:updateInputSource:] + 208
18 UIKitCore 0x00007fff2446c942 -[UIKeyboardImpl _performKeyboardOutput:shouldCheckDelegate:] + 1071
19 UIKitCore 0x00007fff2446c4d3 -[UIKeyboardImpl performKeyboardOutput:] + 25
20 UIKitCore 0x00007fff2446b550 __55-[UIKeyboardImpl handleKeyboardInput:executionContext:]block_invoke_2 + 418
21 UIKitCore 0x00007fff2449e2e5 -[UIKeyboardTaskEntry execute:] + 147
22 UIKitCore 0x00007fff2449cf79 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 310
23 UIKitCore 0x00007fff24487ecb -[UIKeyboardImpl handleKeyEvent:] + 201
24 CoreFoundation 0x00007fff204272fc invoking
+ 140
25 CoreFoundation 0x00007fff204247b6 -[NSInvocation invoke] + 303
26 UIKitCore 0x00007fff24a7a4d3 -[UIRepeatedAction invoke] + 279
27 UIKitCore 0x00007fff24a7a6d3 -[UIRepeatedAction _preInvocationTimerFire] + 45
28 UIKitCore 0x00007fff246b15a5 -[UIApplication _handleKeyboardPressEvent:] + 2625
29 UIKitCore 0x00007fff2469b273 -[UIApplication pressesBegan:withEvent:] + 401
30 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
31 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
32 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
33 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
34 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
35 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
36 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
37 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
38 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
39 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
40 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
41 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
42 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
43 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
44 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
45 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
46 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
47 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
48 UIKitCore 0x00007fff23e5bc9a -[UITabBarController pressesBegan:withEvent:] + 115
49 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
50 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
51 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
52 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
53 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
54 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
55 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
56 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
57 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
58 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
59 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
60 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
61 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
62 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
63 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
64 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
65 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
66 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
67 UIKitCore 0x00007fff246c4823 forwardTouchMethod + 321
68 UIKitCore 0x00007fff246c81c0 -[UIResponder pressesBegan:withEvent:] + 49
69 UIKitCore 0x00007fff249d335a -[UITextField pressesBegan:withEvent:] + 370
70 UIKitCore 0x00007fff246d4229 -[UIWindow _sendButtonsForEvent:] + 393
71 UIKitCore 0x00007fff246d5313 -[UIWindow sendEvent:] + 3550
72 UIKitCore 0x00007fff246af57a -[UIApplication sendEvent:] + 633
73 UIKitCore 0x00007fff246b0204 -[UIApplication _handleKeyUIEvent:] + 625
74 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
75 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
76 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
77 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
78 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
79 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
80 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
81 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
82 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
83 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
84 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
85 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
86 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
87 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
88 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
89 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
90 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
91 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
92 UIKitCore 0x00007fff246c7751 -[UIResponder _handleKeyUIEvent:] + 79
93 UIKitCore 0x00007fff246b02b0 -[UIApplication handleKeyUIEvent:] + 79
94 UIKitCore 0x00007fff246aff73 -[UIApplication handleKeyHIDEvent:] + 538
95 UIKitCore 0x00007fff2473fe62 __processEventQueue + 13481
96 UIKitCore 0x00007fff24736973 __eventFetcherSourceCallback + 104
97 CoreFoundation 0x00007fff2038f38a CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
98 CoreFoundation 0x00007fff2038f282 __CFRunLoopDoSource0 + 180
99 CoreFoundation 0x00007fff2038e764 __CFRunLoopDoSources0 + 248
100 CoreFoundation 0x00007fff20388f2f __CFRunLoopRun + 878
101 CoreFoundation 0x00007fff203886d6 CFRunLoopRunSpecific + 567
102 GraphicsServices 0x00007fff2bededb3 GSEventRunModal + 139
103 UIKitCore 0x00007fff24690e0b -[UIApplication _run] + 912
104 UIKitCore 0x00007fff24695cbc UIApplicationMain + 101
105 libmonosgen-2.0.dylib 0x000000010b067c42 do_icall + 194
106 libmonosgen-2.0.dylib 0x000000010b066c5d do_icall_wrapper + 253
107 libmonosgen-2.0.dylib 0x000000010b058e7a interp_exec_method + 2970
108 libmonosgen-2.0.dylib 0x000000010b0570ff interp_runtime_invoke + 239
109 libmonosgen-2.0.dylib 0x000000010af4ed3b mono_jit_runtime_invoke + 1227
110 libmonosgen-2.0.dylib 0x000000010ae71328 mono_runtime_invoke_checked + 136
111 libmonosgen-2.0.dylib 0x000000010ae780cb mono_runtime_exec_main_checked + 107
112 libmonosgen-2.0.dylib 0x000000010afb11e2 mono_jit_exec + 354
113 libxamarin-dotnet-debug.dylib 0x000000010b4b7e9d xamarin_main + 1949
114 meitiMaui 0x0000000100bb33c4 main + 52
115 ??? 0x000000020128b52e 0x0 + 8609379630
116 ??? 0x0000000000000003 0x0 + 3

@jsuarezruiz jsuarezruiz added platform/iOS 🍎 area-controls-shell Shell Navigation, Routes, Tabs, Flyout area-controls-entry Entry labels Oct 10, 2022
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Oct 10, 2022
@jsuarezruiz jsuarezruiz self-assigned this Oct 10, 2022
@rachelkang rachelkang added this to the Backlog milestone Nov 2, 2022
@ghost
Copy link

ghost commented Nov 2, 2022

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ghost ghost locked as resolved and limited conversation to collaborators Jan 11, 2023
@samhouts samhouts added the fixed-in-7.0.58 Look for this fix in 7.0.58! label Feb 16, 2023
@samhouts samhouts modified the milestones: Backlog, .NET 7 + Servicing Feb 16, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Feb 22, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-entry Entry area-controls-shell Shell Navigation, Routes, Tabs, Flyout fixed-in-7.0.58 Look for this fix in 7.0.58! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants