mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
CanvasRecorder if IMPELLER_TRACE_CANVAS is not set. (flutter/engine#46476)
Internal bug: b/303067268
https://github.com/flutter/engine/pull/46376 is causing a breakage to the internal engine build because of 543348a044/impeller/aiks/canvas_recorder.h (L58-L62). Internally, we do not set `IMPELLER_TRACE_CANVAS`.
It looks like the cause is that the internal toolchain causes the `static_assert` to be compiled even though the template is not instantiated.
@chingjun helped me to figure out the following:
https://stackoverflow.com/questions/5246049/c11-static-assert-and-template-instantiation points us to the spec. In the later version (ISO/IEC 14882:2017(E)):
> The program is ill-formed, no diagnostic required, if ... no valid specialization can be generated for a template or a substatement of a constexpr if statement (9.4.1) within a template and the template is not instantiated,
<details>
<summary>The relevant section</summary>

</details>
Interpretation: the compiler can either choose to emit the error caused by the `static_assert` or not. Currently the compiler used by the build here on LUCI does not; internally it does.
For example, the following links shows that simply changing the Clang version affects whether the error appears or not for a minimal template.
- ok: https://godbolt.org/z/n9nYrcvcP
- not ok: https://godbolt.org/z/fWcvdcn35
Hence, `#ifdef` out the class instead of using a `static_assert` for more consistent behavior across these two toolchains.
[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Description
Flutter makes it easy and fast to build beautiful apps for mobile and beyond
androidapp-frameworkcross-platformdartdart-platformdesktopflutterflutter-packagefuchsiaioslinux-desktopmacosmaterial-designmobilemobile-developmentskiawebweb-frameworkwindows
2.5 GiB
Languages
Dart
75%
C++
16.5%
Objective-C++
2.9%
Java
2.8%
Objective-C
0.7%
Other
1.9%