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

BarcodeGeneratorView throws an unhandled exception in case QR content is too big #166

Open
vicocz opened this issue Feb 8, 2024 · 0 comments

Comments

@vicocz
Copy link

vicocz commented Feb 8, 2024

If string content passed to BarcodeGeneratorView component running in BarcodeFormat.QrCode mode, inner BarcodeGeneratorViewHandler throws ZXing.WriterException and MAUI application crashes.

ZXing.WriterException
  Message=Data too big
  Source=zxing
  StackTrace:
   at ZXing.QrCode.Internal.Encoder.chooseVersion(Int32 numInputBits, ErrorCorrectionLevel ecLevel)
   at ZXing.QrCode.Internal.Encoder.recommendVersion(ErrorCorrectionLevel ecLevel, Mode mode, BitArray headerBits, BitArray dataBits)
   at ZXing.QrCode.Internal.Encoder.encode(String content, ErrorCorrectionLevel ecLevel, IDictionary`2 hints)
   at ZXing.QrCode.QRCodeWriter.encode(String contents, BarcodeFormat format, Int32 width, Int32 height, IDictionary`2 hints)
   at ZXing.MultiFormatWriter.encode(String contents, BarcodeFormat format, Int32 width, Int32 height, IDictionary`2 hints)
   at ZXing.BarcodeWriterGeneric.Encode(String contents)
   at ZXing.BarcodeWriter`1[[Android.Graphics.Bitmap, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].Write(String contents)
   at ZXing.Net.Maui.BarcodeGeneratorViewHandler.UpdateBarcode()
   at ZXing.Net.Maui.BarcodeGeneratorViewHandler.ConnectHandler(ImageView nativeView)
   at Microsoft.Maui.Handlers.ViewHandler`2[[ZXing.Net.Maui.IBarcodeGeneratorView, ZXing.Net.MAUI, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[Android.Widget.ImageView, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065]].OnConnectHandler(View platformView) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandlerOfT.cs:line 76
   at Microsoft.Maui.Handlers.ViewHandler.OnConnectHandler(Object platformView) in D:\a\_work\1\s\src\Core\src\Handlers\View\ViewHandler.cs:line 204

This edge scenario should be somehow handled so as:

  • application does not crash
  • BarcodeGeneratorView somehow reports invalid input
@vicocz vicocz changed the title BarcodeGeneratorView thorws an unhandled exception in case QR content is too big BarcodeGeneratorView throws an unhandled exception in case QR content is too big Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant