Skip to content

Application crashed on hotreload when renaming uniforms and using getUniformFloat #180101

@walley892

Description

@walley892

Steps to reproduce

  1. Have some dart code that sets the value of a uniform for a custom shader using getUniformFloat

  2. Change the name of the uniform in both the dar code and the shader

  3. Hot reload

Expected results

No change to the program at all.

Actual results

Program crashes :(

Code sample

Code sample
  void paint(Canvas canvas, Size size) {
    shader.setFloat(0, size.width);
    shader.setFloat(1, size.height);
    shader.getUniformFloat('uTime').set(time);

    final paint = Paint()..shader = shader;
    canvas.drawRect(Offset.zero & size, paint);
  }

With the shader:

uniform vec2 uSize;

uniform float uTime;

void main() {
  vec2 uv = FlutterFragCoord().xy / uSize;

  vec4 color1 = vec4(0.4, 0.0, 0.5, 1.0); 
  vec4 color2 = vec4(0.0, 0.4, 0.2, 1.0);

  fragColor = mix(color1, color2, abs(sin(uTime)));
}

Load up the program and everything looks fine.

Then rename the uniform in both dart and glsl:

  void paint(Canvas canvas, Size size) {
    shader.setFloat(0, size.width);
    shader.setFloat(1, size.height);
    shader.getUniformFloat('uTim').set(time);

    final paint = Paint()..shader = shader;
    canvas.drawRect(Offset.zero & size, paint);
  }

With the shader:

uniform vec2 uSize;

uniform float uTim;

void main() {
  vec2 uv = FlutterFragCoord().xy / uSize;

  vec4 color1 = vec4(0.4, 0.0, 0.5, 1.0); 
  vec4 color2 = vec4(0.0, 0.4, 0.2, 1.0);

  fragColor = mix(color1, color2, abs(sin(uTim)));
}

Screenshots or Video

Logs

Flutter Doctor output

N/A

Metadata

Metadata

Assignees

Labels

e: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions