theyakka / qr.flutter

QR.Flutter is a Flutter library for simple and fast QR code rendering via a Widget or custom painter.
https://pub.dev/packages/qr_flutter
BSD 3-Clause "New" or "Revised" License
718 stars 323 forks source link

Broken QR codes due to style position error. #194

Open AdrienLemaire opened 2 years ago

AdrienLemaire commented 2 years ago

Describe the bug The corners' inner squares aren't always aligned, which breaks the QR code (unscannable). I can only reproduce the bug on a mobile chrome web browser (which is the target we focus on), seems to always work fine on a chrome desktop (I can still reproduce using the debugger device toolbox to simulate a mobile device from desktop).

Seems related to #182

Expected behavior The inner squares should be properly centered

Screenshots Identical page, different position mode:

Portrait (broken):

Landscape (working):

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Seems to be a styling issue, but I don't know how to debug this kind of error. Untitled

AdrienLemaire commented 2 years ago

After trying to debug this issue further, I understand that canvas.drawRRect receives the exact same values to place the eyes, but when the device type is "mobile", the outerRect will have a wrong left & top offset added. Changing the DPR doesn't have any effect, but for the same viewport, changing the device type has an effect ("desktop" works, "mobile" breaks).

Values passed to Rect.fromLTWH in both cases

*** Drawing square eye
outerRect: 8, 8, 57, 57
innerRect: 17.5, 17.5, 38, 38
dotRect: 22.25, 22.25, 28.5, 28.5
*** Drawing square eye
outerRect: 8, 255, 57, 57
innerRect: 17.5, 264.5, 38, 38
dotRect: 22.25, 269.25, 28.5, 28.5
*** Drawing square eye
outerRect: 255, 8, 57, 57
innerRect: 264.5, 17.5, 38, 38
dotRect: 269.25, 22.25, 28.5, 28.5

mobile:

desktop:

AdrienLemaire commented 2 years ago

2nd insight: This could be a Chrome-specific bug. Opening the page in a webview (for example, by scanning the QR code and navigate to that website) works fine (creating a QR code will diplay the eyes properly).

AdrienLemaire commented 2 years ago

pinging the authors for help: @lukef @kevmoo @romkor @cretezy @kelegorm @pedromassango @lukepighetti @jonas-zebari

kevmoo commented 2 years ago

I THINK this is due to drawing logic. Put in the same input here: https://kevmoo.github.io/qr.dart/ - which uses browser APIs (Dart, but not flutter)

BraveEvidence commented 1 year ago

This might help https://www.youtube.com/watch?v=9ADSWmPCJMg&list=PLQhQEGkwKZUqZC2QAp_u4ZAzqpsCCRvmM&index=6 https://www.youtube.com/watch?v=ZRUE1i15TYw&list=PLQhQEGkwKZUqZC2QAp_u4ZAzqpsCCRvmM&index=7