Repository: flutter
Issue: Wrong canvas scale (web)
Labels: engine,platform-web,has reproducible steps,P2,found in release: 2.0,found in release: 2.1,team-web,triaged-web

It seems that the canvas does a wrong rounding on the scale when using doubles with many decimal places.

Code:

```dart
import 'package:flutter/material.dart';
import 'dart:math' as math;

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    CustomPaint customPaint = CustomPaint(
        child: Container(
          decoration: BoxDecoration(border: Border.all(color: Colors.black)),
        ),
        painter: MyCustomPainter());

    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
          body: Padding(
        child: customPaint,
        padding: EdgeInsets.all(30),
      )),
    );
  }
}

class MyCustomPainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    canvas.save();

    bool moreDecimalPlaces = true;

    Path path = Path();
    if (moreDecimalPlaces) {
      path.moveTo(100.0039, 20.0026);
      path.lineTo(100.0039, 20.0021);
      path.lineTo(100.0041, 20.0021);
      path.lineTo(100.0041, 20.0026);
    } else {
      path.moveTo(100.039, 20.026);
      path.lineTo(100.039, 20.021);
      path.lineTo(100.041, 20.021);
      path.lineTo(100.041, 20.026);
    }

    // fit and center on screen
    Rect pathBounds = path.getBounds();
    double sx = size.width / pathBounds.width;
    double sy = size.height / pathBounds.height;
    double s = math.min(sx, sy);
    double tx = (size.width / 2.0) - (s * pathBounds.center.dx);
    double ty = (size.height / 2.0) - (s * pathBounds.center.dy);
    canvas.translate(tx, ty);
    canvas.scale(s);

    var paint = Paint()
      ..style = PaintingStyle.fill
      ..color = Colors.blue
      ..isAntiAlias = true;

    canvas.drawPath(path, paint);

    canvas.restore();
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => false;
}
```

Few decimal places:

![ok](https://user-images.githubusercontent.com/8809484/113636667-56ebb900-9649-11eb-860d-63488a34a62b.gif)

Many decimal places:

![wrong](https://user-images.githubusercontent.com/8809484/113636684-5d7a3080-9649-11eb-8cbe-ecbdd7364308.gif)

Flutter doctor:

```
[✓] Flutter (Channel stable, 2.0.4, on Linux, locale en_US.UTF-8)
    • Flutter version 2.0.4 at /home/cadu/desenv/flutter
    • Framework revision b1395592de (4 days ago), 2021-04-01 14:25:01 -0700
    • Engine revision 2dce47073a
    • Dart version 2.12.2

[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /home/cadu/Android/Sdk
    • Platform android-30, build-tools 30.0.3
    • ANDROID_SDK_ROOT = /home/cadu/Android/Sdk
    • Java binary at: /home/cadu/desenv/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/linux#android-setup for more details.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio
    • Android Studio at /home/cadu/desenv/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /home/cadu/desenv/android-studio
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Community Edition (version 2020.3)
    • IntelliJ at /home/cadu/desenv/idea-IC-203.6682.168
    • Flutter plugin version 54.0.3
    • Dart plugin version 203.7759

[✓] Connected device (1 available)
    • Chrome (web) • chrome • web-javascript • Google Chrome 89.0.4389.114

! Doctor found issues in 1 category.
```