)]}'
{
  "commit": "ef089e25c8f2b06bcb8f456fbb5474e56855a275",
  "tree": "5e02be86622f2b4cf9d9743199be159fb744e961",
  "parents": [
    "74701fbc0a3a19612b18edd138df85603ba4d596"
  ],
  "author": {
    "name": "b-luk",
    "email": "97480502+b-luk@users.noreply.github.com",
    "time": "Fri Jul 31 15:32:24 2026 -0700"
  },
  "committer": {
    "name": "GitHub",
    "email": "noreply@github.com",
    "time": "Fri Jul 31 22:32:24 2026 +0000"
  },
  "message": "Eliminate some early returns in uber_sdf.frag to fix broken UberSDF AA on Windows (#190260)\n\nSee\nhttps://github.com/flutter/flutter/issues/189827#issuecomment-5108403591\nfor some more context. That comment shows 2 issues:\n1. UberSDF AA is broken on Windows\n2. Tessellated AA is broken on OpenGLES\n\nFixes\nhttps://github.com/flutter/flutter/issues/189827#issuecomment-5108403591\n\nThis PR fixes the first issue. The second issue is tracked at\nhttps://github.com/flutter/flutter/issues/190060.\n\nThis PR flattens some branching in uber_sdf.frag to eliminate some early\nreturns.\n\nSomething about the dFdx and dFdy derivatives are incompatible with\nANGLE and/or D3D, making uberSDF antialiasing fail on Windows. I don\u0027t\nknow what the exact limits are of when dFdx and dFdy are allowed. From\nasking Gemini, it may be related to branching, non-uniform branching,\nloops, or early return statements. After some manual testing,\neliminating early return statements in functions which use dFdx and dFdy\n(either directly, or indirectly through a child call) seems sufficient\nto fix this.\n\n### Demo app\n\n\u003cdetails\u003e \u003csummary\u003eDemo:\u003c/summary\u003e\n\n```dart\nimport \u0027package:flutter/material.dart\u0027;\n\nvoid main() {\n  runApp(MyApp());\n}\n\nclass MyApp extends StatelessWidget {\n  @override\n  Widget build(BuildContext context) {\n    return InteractiveViewer(\n      maxScale: 10,\n      child: Container(\n        color: Colors.black,\n        child: CustomPaint(painter: TestPainter()),\n      ),\n    );\n  }\n}\n\nclass TestPainter extends CustomPainter {\n  @override\n  void paint(Canvas canvas, Size size) {\n    var filledPaint \u003d Paint()..color \u003d Colors.white;\n    var strokedPaint \u003d Paint()\n      ..color \u003d Colors.white\n      ..style \u003d PaintingStyle.stroke\n      ..strokeWidth \u003d 5;\n    const rect \u003d Rect.fromLTWH(20, 20, 30.5, 15.5);\n\n    // circle\n    canvas.drawCircle(Offset(35, 25), 15.5, filledPaint);\n    canvas.save();\n    canvas.translate(50, 0);\n    canvas.drawCircle(Offset(35, 25), 15.5, strokedPaint);\n    canvas.restore();\n\n    // oval\n    canvas.translate(0, 50);\n    canvas.drawOval(rect, filledPaint);\n    canvas.save();\n    canvas.translate(50, 0);\n    canvas.drawOval(rect, strokedPaint);\n    canvas.restore();\n\n    // rounded rect\n    canvas.translate(0, 50);\n    canvas.drawRRect(RRect.fromRectAndRadius(rect, .circular(5)), filledPaint);\n    canvas.save();\n    canvas.translate(50, 0);\n    canvas.drawRRect(\n      RRect.fromRectAndRadius(rect, .circular(5)),\n      strokedPaint,\n    );\n    canvas.restore();\n\n    // column 2\n    canvas.translate(120, -150);\n\n    // rect\n    canvas.translate(0, 50);\n    canvas.drawRect(rect, filledPaint);\n    canvas.save();\n    canvas.translate(50, 0);\n    canvas.drawRect(rect, strokedPaint);\n    canvas.restore();\n\n    // rotated rect\n    canvas.translate(0, 50);\n    canvas.save();\n    canvas.rotate(0.3);\n    canvas.drawRect(rect, filledPaint);\n    canvas.restore();\n    canvas.save();\n    canvas.translate(50, 0);\n    canvas.rotate(0.3);\n    canvas.drawRect(rect, strokedPaint);\n    canvas.restore();\n\n    // RSuperellipse\n    canvas.translate(0, 50);\n    canvas.drawRSuperellipse(\n      RSuperellipse.fromRectAndRadius(rect, .circular(5)),\n      filledPaint,\n    );\n    canvas.save();\n    canvas.translate(50, 0);\n    canvas.drawRSuperellipse(\n      RSuperellipse.fromRectAndRadius(rect, .circular(5)),\n      strokedPaint,\n    );\n    canvas.restore();\n  }\n\n  @override\n  bool shouldRepaint(covariant CustomPainter oldDelegate) \u003d\u003e false;\n}\n\n```\n\n\u003c/details\u003e\n\n### Before:\n\n\u003cimg width\u003d\"232\" height\u003d\"189\" alt\u003d\"image\"\nsrc\u003d\"https://github.com/user-attachments/assets/ef75b0ea-62be-49a6-9c20-1507ed9e1435\"\n/\u003e\n\n500% zoom:\n\u003cimg width\u003d\"1150\" height\u003d\"938\" alt\u003d\"image\"\nsrc\u003d\"https://github.com/user-attachments/assets/e199cbf1-222c-4e1d-b250-e5649b212e86\"\n/\u003e\n\n\n### After:\n\n\u003cimg width\u003d\"232\" height\u003d\"189\" alt\u003d\"image\"\nsrc\u003d\"https://github.com/user-attachments/assets/181c9316-e3f1-4b10-b474-fdc2baf74e50\"\n/\u003e\n\n500% zoom:\n\u003cimg width\u003d\"1150\" height\u003d\"938\" alt\u003d\"image\"\nsrc\u003d\"https://github.com/user-attachments/assets/26783e17-d5de-46f3-a0af-9b8801aeb122\"\n/\u003e\n\nNotice that stroked RSuperellipse does not have AA. This confused me for\na long time. Eventually I figured out that stroked RSuperellipse is\n[always drawn with a\npath](https://github.com/flutter/flutter/blob/b1ae9ca144127fa87eb86d0cdf73f6c028964ec3/engine/src/flutter/display_list/dl_builder.cc#L1371-L1378).\nSo it does not go through the UberSDF code. Paths render with\ntessellation, which is supposed to use MSAA but is currently not\nfunctioning properly on Windows.\n\n\n## Pre-launch Checklist\n\n- [x] I read the [Contributor Guide] and followed the process outlined\nthere for submitting PRs.\n- [x] I read the [AI contribution guidelines] and understand my\nresponsibilities, or I am not using AI tools.\n- [x] I read the [Tree Hygiene] wiki page, which explains my\nresponsibilities.\n- [x] I read and followed the [Flutter Style Guide], including [Features\nwe expect every widget to implement].\n- [x] I signed the [CLA].\n- [x] I listed at least one issue that this PR fixes in the description\nabove.\n- [x] I updated/added relevant documentation (doc comments with `///`).\n- [ ] I added new tests to check the change I am making, or this PR is\n[test-exempt].\n- [x] I followed the [breaking change policy] and added [Data Driven\nFixes] where supported.\n- [ ] All existing and new tests are passing.\n\nIf you need help, consider asking for advice on the #hackers-new channel\non [Discord].\n\nIf this change needs to override an active code freeze, provide a\ncomment explaining why. The code freeze workflow can be overridden by\ncode reviewers. See pinned issues for any active code freezes with\nguidance.\n\n**Note**: The Flutter team is currently trialing the use of [Gemini Code\nAssist for\nGitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).\nComments from the `gemini-code-assist` bot should not be taken as\nauthoritative feedback from the Flutter team. If you find its comments\nuseful you can update your code accordingly, but if you are unsure or\ndisagree with the feedback, please feel free to wait for a Flutter team\nmember\u0027s review for guidance on which automated comments should be\naddressed.\n\n\u003c!-- Links --\u003e\n[Contributor Guide]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview\n[AI contribution guidelines]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#ai-contribution-guidelines\n[Tree Hygiene]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md\n[test-exempt]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests\n[Flutter Style Guide]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md\n[Features we expect every widget to implement]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement\n[CLA]: https://cla.developers.google.com/\n[flutter/tests]: https://github.com/flutter/tests\n[breaking change policy]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes\n[Discord]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md\n[Data Driven Fixes]:\nhttps://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md\n\n---------\n\nCo-authored-by: gaaclarke \u003c30870216+gaaclarke@users.noreply.github.com\u003e",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "d291dfc4a398010037ae9e3e5a11820a2629cc44",
      "old_mode": 33188,
      "old_path": "engine/src/flutter/impeller/entity/shaders/uber_sdf.frag",
      "new_id": "97a5f5b715928004c33b666f9f7891f572ab8907",
      "new_mode": 33188,
      "new_path": "engine/src/flutter/impeller/entity/shaders/uber_sdf.frag"
    },
    {
      "type": "modify",
      "old_id": "da2d4782141bc9124c000b8e91b2af05e2e88c0f",
      "old_mode": 33188,
      "old_path": "engine/src/flutter/impeller/tools/malioc.json",
      "new_id": "d93c1e6ad6f2d20fa45ba6373c137cce078e5d43",
      "new_mode": 33188,
      "new_path": "engine/src/flutter/impeller/tools/malioc.json"
    }
  ]
}
