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

Setting TextBox.Foreground produces NullReferenceException on Android device #5491

Closed
3 of 24 tasks
s-beltz opened this issue Mar 17, 2021 · 4 comments · Fixed by #5738
Closed
3 of 24 tasks

Setting TextBox.Foreground produces NullReferenceException on Android device #5491

s-beltz opened this issue Mar 17, 2021 · 4 comments · Fixed by #5738
Assignees
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working project/input ⌨️ Categorizes an issue or PR as relevant to input (Button, CheckBox, Toggle, Scroll, Map, Numeric,...)
Milestone

Comments

@s-beltz
Copy link

s-beltz commented Mar 17, 2021

Current behavior

If setting TextBox.Foreground property Android devices will produce the following NullReferenceException:

Java.Lang.NoSuchFieldException   Message=No field mCursorDrawableRes in class Landroid/widget/TextView; (declaration of 'android.widget.TextView' appears in /system/framework/framework.jar!classes3.dex)
$exception    {System.NullReferenceException: Object reference not set to an instance of an object. 
at Windows.UI.Xaml.Controls.TextBoxView+EditTextCursorColorChanger.SetCursorColor (Android.Widget.EditText editText, Windows.UI.Color color) [0x00012] 
in C:\a\1\s\src\Uno.UI\UI\Xaml\Controls\TextBox\TextBoxView.Android.cs:162 }    System.NullReferenceException

Expected behavior

How to reproduce it (as minimally and precisely as possible)

Workaround

Environment

Nuget Package:

  • Uno.UI / Uno.UI.WebAssembly / Uno.UI.Skia
  • Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia
  • Uno.SourceGenerationTasks
  • Uno.UI.RemoteControl / Uno.WinUI.RemoteControl
  • Other:

Nuget Package Version(s):
Uno.UI Version="3.6.0-dev.459"

Affected platform(s):

  • iOS
  • Android
  • WebAssembly
  • WebAssembly renderers for Xamarin.Forms
  • macOS
  • Skia
    • WPF
    • GTK (Linux)
    • Tizen
  • Windows
  • Build tasks
  • Solution Templates

IDE:

  • Visual Studio 2017 (version: )
  • Visual Studio 2019 (version: 16.9.2)
  • Visual Studio for Mac (version: )
  • Rider Windows (version: )
  • Rider macOS (version: )
  • Visual Studio Code (version: )

Relevant plugins:

  • Resharper (version: )

Anything else we need to know?

@s-beltz s-beltz added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Mar 17, 2021
@jeromelaban jeromelaban added difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers project/input ⌨️ Categorizes an issue or PR as relevant to input (Button, CheckBox, Toggle, Scroll, Map, Numeric,...) and removed difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. triage/untriaged Indicates an issue requires triaging or verification labels Mar 17, 2021
@kazo0 kazo0 self-assigned this Mar 30, 2021
@kazo0 kazo0 added this to the 3.7 milestone Mar 30, 2021
@kazo0
Copy link
Contributor

kazo0 commented Mar 31, 2021

@s-beltz Having trouble reproducing this one, does this result in an application crash? I see the code that is being referenced is wrapped in a try/catch so it shouldn't be throwing an exception.

Which version of the Uno.UI package are you using?

@s-beltz
Copy link
Author

s-beltz commented Mar 31, 2021

@kazo0 we observed this exception only on real hardware (Lenovo Tab M10) . The simulator does not show the exception. We last tested with Uno.UI "3.6.0-dev.459"

@ibebbs
Copy link

ibebbs commented Apr 7, 2021

Also seeing this issue on physical hardware (Honor View 20) but I'm not [explicitly] setting the foreground. It happens just by having an empty <TextBox/> element in the XAML and seems to screw up subsequent layout of the page.

I've tried both v3.5.1 & v3.6.6 of Uno.UI.

A broader search provides a couple of hits related to Material design. Could it be related?

@davidjohnoliver
Copy link
Contributor

@ibebbs Uno's Material implementation is all XAML-based, so it's probably not directly related to the other reports.

Can you post the exact stack trace you're getting? It's strange that it should interrupt the layout, since as @kazo0 said the attempt to set the native caret foreground is wrapped in a try/catch and it's expected that it should fail (harmlessly) on some devices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/starter 🚀 Categorizes an issue for which the difficulty level is reachable by newcomers kind/bug Something isn't working project/input ⌨️ Categorizes an issue or PR as relevant to input (Button, CheckBox, Toggle, Scroll, Map, Numeric,...)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants