Crash when geometries are too complex to enconde in the QR code

Open Beginner friendly
#3,933 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
68/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
kotlin
Domain
mobile

Research direction

Start at encodeQrBitmap in QrCodeGenerator.android.kt:38 and follow its use from GroundQrCode.kt:67. Reproduce the crash with oversized geometry or long survey data, then verify that the QR-code flow handles the ZXing WriterException instead of crashing.

Written by the indexing model from the issue text.

Description

type: bug

Crashlytics

The QR code is missing error handling when the encoded data is too large. This could be due to geometries with many vertices or long LOI/survey names, which can make the geoJSON too big to be displayed as a QR code.

Fatal Exception: com.google.zxing.WriterException: Data too big
       at com.google.zxing.qrcode.encoder.Encoder.chooseVersion(Encoder.java:320)
       at com.google.zxing.qrcode.encoder.Encoder.recommendVersion(Encoder.java:218)
       at com.google.zxing.qrcode.encoder.Encoder.encode(Encoder.java:152)
       at com.google.zxing.qrcode.QRCodeWriter.encode(QRCodeWriter.java:78)
       at org.groundplatform.ui.components.qrcode.QrCodeGenerator_androidKt.encodeQrBitmap(QrCodeGenerator.android.kt:38)
       at org.groundplatform.ui.components.qrcode.GroundQrCodeKt$GroundQrCode$qrBitmap$2$1$1.invokeSuspend(GroundQrCode.kt:67)
       at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
       at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
       at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:807)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
       at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)
Dominant language
Kotlin
Stars
294
Forks
149
Avg merge
1d 14h
Merged PRs (30d)
48

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from google/ground-android

All issues in google/ground-android

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.