Skip to content

[web:html] off by one error in paragraph height measurement in Chrome 96+ #99933

@yjbanov

Description

@yjbanov

In Chrome versions 96 or newer the HTML renderer measures text slightly differently from other renderers. This bug requires a special case in cupertino/dialog_test.dart.

To reproduce

Make sure you have Chrome 96 or newer (this was reproducible in Chrome 96 in LUCI, and in Chrome 98 locally).

Sync to Flutter revision 8f58af8.

Run the test below in these modes:

  • flutter test
  • flutter test --platform=chrome --web-renderer=canvaskit
  • flutter test --web-renderer=html:

Test:

  testWidgets('Off by 1px', (WidgetTester tester) async {
    final ui.ParagraphBuilder b = ui.ParagraphBuilder(ui.ParagraphStyle(
      textDirection: ui.TextDirection.ltr,
    ));
    b.pushStyle(ui.TextStyle(
      fontWeight: FontWeight.w600,
      letterSpacing: -0.5,
      fontSize: 51,
      height: 1.3,
    ));
    b.addText('The Title');
    b.pop();

    final ui.Paragraph p = b.build();
    p.layout(const ui.ParagraphConstraints(width: double.infinity));
    print('Height: ${p.height}');
  });

Expected behavior

In all cases the printed value of p.height should be exactly 66.

Actual behavior

The VM and CanvasKit modes print 66. However, the HTML renderer prints 66.296875.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: typographyText rendering, possibly libtxte: web_htmlHTML rendering backend for Webengineflutter/engine related. See also e: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions