google / google/ground-android

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
type: bug
Dominant language
Kotlin
Stars
293
Forks
149
Avg merge
1d 16h
Merged PRs (30d)
42

Description

[Crashlytics](https://console.firebase.google.com/u/0/project/of-ground/crashlytics/app/android:org.openforis.ground/issues/53c3f6a31b18a42fa61e1e52b7e70aa1?time=7d&types=crash&sessionEventKey=6AA1E6F003130001549A43805F8C117A_2262127932473465542)

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)
```

Contributor guide

Open the contributing guide

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.