Repository: flutter
Issue: FragmentProgram.fromAsset on skia fails to compile a for loop
Labels: engine,P2,team-engine,triaged-engine

`FragmentProgram.fromAsset` on skia fails to compile a for loop.

This only happens on skia renderer, works fine on impeller, but I'm not sure if it's possible to do `flutter test` with impeller on.

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Execute `flutter test` on the code sample.

**Expected results:** 
Mandelbrot image gets rendered into mandelbrot.png.

**Actual results:**
Test fails because shader fails to compile.
```
  SkSL Error:
  error: 20: missing init declaration
      for (; i < 100; i++)
           ^
  1 error
  
  dart:ui                         FragmentProgram.fromAsset
  package:fractal/main.dart 7:26  fromAsset
  test/shader_test.dart 25:25     renderShader
  test/shader_test.dart 21:28     main.<fn>
```


<details>
<summary>Code sample</summary>



[Archive.zip](https://github.com/flutter/flutter/files/10201864/Archive.zip)

The failing shader:
```glsl
#version 320 es
precision highp float;

const int iter = 100;

layout(location = 0) uniform vec2 center;
layout(location = 2) uniform vec2 size;
layout(location = 4) uniform float scale;

layout(location = 0) out vec4 oColor;

void main() {
    vec2 coord = gl_FragCoord.xy / size;
    float aspectRatio = size.x / size.y;

    vec2 z, c;

    c.x = aspectRatio * (coord.x - 0.5) * scale - center.x;
    c.y = (coord.y - 0.5) * scale - center.y;

    int i;
    for(i=0; i< iter; i++) {
        float x = (z.x * z.x - z.y * z.y) + c.x;
        float y = (z.y * z.x + z.x * z.y) + c.y;

        if((x * x + y * y) > 4.0) {
            break;
        }
        z.x = x;
        z.y = y;
    }
    
    oColor.r = i == iter ? 0.0 : float(i) / float(iter);
    oColor.a = 1.0;
}
```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->

```
szotp@MacBook-Pro-Pawel mandelbrot_minimal % flutter test      
00:01 +1 -1: mandelbrot [E]                                                                                                                                                                                         
  Exception: Invalid SkSL:
  // This SkSL shader is autogenerated by spirv-cross.
  
  float4 flutter_FragCoord;
  
  uniform vec2 center;
  uniform vec2 size;
  uniform float scale;
  
  vec4 oColor;
  
  void FLT_main()
  {
      vec2 coord = flutter_FragCoord.xy / size;
      float aspectRatio = size.x / size.y;
      vec2 c;
      c.x = ((aspectRatio * (coord.x - 0.5)) * scale) - center.x;
      c.y = ((coord.y - 0.5) * scale) - center.y;
      int i = 0;
      vec2 z;
      for (; i < 100; i++)
      {
          float x = ((z.x * z.x) - (z.y * z.y)) + c.x;
          float y = ((z.y * z.x) + (z.x * z.y)) + c.y;
          if (((x * x) + (y * y)) > 4.0)
          {
              break;
          }
          z.x = x;
          z.y = y;
      }
      float _122;
      if (i == 100)
      {
          _122 = 0.0;
      }
      else
      {
          _122 = float(i) / 100.0;
      }
      oColor.x = _122;
      oColor.w = 1.0;
  }
  
  half4 main(float2 iFragCoord)
  {
        flutter_FragCoord = float4(iFragCoord, 0, 0);
        FLT_main();
        return oColor;
  }
  
  SkSL Error:
  error: 20: missing init declaration
      for (; i < 100; i++)
           ^
  1 error
  
  dart:ui                      FragmentProgram.fromAsset
  test/shader_test.dart 53:41  renderShader
  test/shader_test.dart 21:28  main.<fn>
  

To run this test again: /Users/szotp/flutter-sdk/bin/cache/dart-sdk/bin/dart test /Users/szotp/Projects/mandelbrot_minimal/test/shader_test.dart -p vm --plain-name 'mandelbrot'
00:01 +1 -1: Some tests failed.     
```

```
[✓] Flutter (Channel master, 3.7.0-5.0.pre.21, on macOS 13.0 22A380 darwin-arm64, locale en-GB)
[!] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS (Xcode 14.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.2)
[✓] VS Code (version 1.74.0)
[✓] Connected device (5 available)
[✓] HTTP Host Availability

! Doctor found issues in 1 category.
```

</details>