Skip to content

[Impeller] shaders do not load immediately at application start. #164757

@itspectre

Description

@itspectre

Steps to reproduce

  1. create a new flutter project
  2. write the code below in main.dart
  3. create a folder named "shaders"
  4. in the folder "shaders", create a file named "one.frag"
  5. write the code below in one.frag
  6. in pubspec.yaml add the following:
    shaders:
    - shaders/one.frag
  7. get a physical Android device with OpenGL ES (not Vulkan) and run the app on it.
  8. Change something in one.frag, then do hot reload and hot restart - nothing happens
  9. Comment the pointed line in main.dart
  10. Relaunch the app (NOT hot restart) - it will (probably) crash
  11. uncomment that line and run the app again - it (probably) runs normally with the new shader view

Expected results

Shaders loading without app crashing and are updated on hot reload and hot restart after changes to shader files.

Actual results

Starting to load a shader immediately after launching the application leads to a crash (very often, but not always). If I set enough delay before loading the shader, there will usually be no problems.
Also, changes to the shader files do not load after hot reload and hot restart, but require a complete app relaunch, which makes it extremely inconvenient to debug shaders.
Both of these problems occur only on the OpenGLES Impeller (tested only on Android). If Vulkan or Skia is used, there are no such problems.
In version 3.29.0, the problems were on Alcatel 6056H (Android 11), which uses OpenGL ES, but after upgrading to version 3.29.1, another device, Samsung Galaxy A51 (Android 12), starts using OpenGL ES instead of Vulkan (as before in version 3.29.0), and I get the same (or very similar) problems with shaders there.

Code sample

Code sample main.dart
import 'dart:ui';
import 'package:flutter/material.dart';

late FragmentProgram program;
late FragmentShader shader;

void main() async {
  await Future.delayed(const Duration(seconds: 6)); // <- comment this
  program = await FragmentProgram.fromAsset('shaders/one.frag');
  shader = program.fragmentShader();
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return ShaderMask(
      blendMode: BlendMode.src,
      shaderCallback: (rect) {
        shader.setFloat(0, rect.width);
        shader.setFloat(1, rect.height);
        return shader;
      },
      child: ColoredBox(color: Colors.black, child: SizedBox.expand()),
    );
  }
}

shaders/one.frag

#include <flutter/runtime_effect.glsl>
uniform vec2 uSize;
out vec4 fragColor;

void main() {
  vec2 uv = FlutterFragCoord().xy / uSize;
  fragColor = vec4(uv.x, 0.0, uv.y, 1.0);
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
Launching lib\main.dart on 6056H in debug mode...
Running Gradle task 'assembleDebug'...
           1 357ms
√ Built build\app\outputs\flutter-apk\app-debug.apk
Installing build\app\outputs\flutter-apk\app-debug.apk...           5,7s
I/flutter ( 4052): [INFO:flutter/shell/platform/android/android_context_vk_impeller.cc(64)] Known bad Vulkan driver encountered, falling back to OpenGLES.        
I/flutter ( 4052): [IMPORTANT:flutter/shell/platform/android/android_context_gl_impeller.cc(94)] Using the Impeller rendering backend (OpenGLES).
E/flutter ( 4052): [ERROR:flutter/impeller/entity/contents/content_context.cc(297)] Break on 'ImpellerValidationBreak' to inspect point of failure: Failed to create empty texture.
Syncing files to device 6056H...
              42ms

Flutter run key commands.
r Hot reload.
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave
application running).
c Clear the screen
q Quit (terminate the application on the device).     

A Dart VM Service on 6056H is available at:
http://127.0.0.1:55884/aqxM9VgXWwg=/
The Flutter DevTools debugger and profiler on 6056H isavailable at:
http://127.0.0.1:9108?uri=http://127.0.0.1:55884/aqxM9VgXWwg=/
I/Choreographer( 4052): Skipped 242 frames!  The application may be doing too much work on its main thread. 
D/libMEOW ( 4052): applied 1 plugins for [com.example.flutter_image_filter_test]:
D/libMEOW ( 4052):   plugin 1: [libMEOW_gift.so]:
I/libMEOW_gift( 4052): ctx:0xb400007cb83e53c0, ARC not Enabled.
D/libMEOW ( 4052): applied 1 plugins for [com.example.flutter_image_filter_test]:
D/libMEOW ( 4052):   plugin 1: [libMEOW_gift.so]:
E/ion     ( 4052): ioctl c0044901 failed with code -1: Invalid argument
F/libc    ( 4052): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x21 in tid 4123 (1.raster), 
pid 4052 (age_filter_test)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'Alcatel/6056H_RU/Hong_Kong_Pro:11/RP1A.200720.011/ANAZ:user/release-keys'
Revision: '0'
ABI: 'arm64'
Timestamp: 2025-03-07 02:29:24+0300
pid: 4052, tid: 4123, name: 1.raster  >>> com.example.flutter_image_filter_test <<<
uid: 10280
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 
0x21
Cause: null pointer dereference
    x0  b400007ce83cd568  x1  b400007d483b14e0  x2  0000000000000000  x3  0000000000000000
    x4  000000000000826b  x5  0000000000000008  x6  b400007c784130a9  x7  0000000100000001
    x8  0000000000000001  x9  0000000000000000  x10 b400007e483e05a8  x11 b400007d5839e160
    x12 0000000000000001  x13 0000000100000001  x14 0001d9075e93b6c0  x15 0000000000000000
    x16 0000007c2b0b8b18  x17 0000007ed97883e0  x18 0000007bca8e2000  x19 b400007cb83e46d0
    x20 b400007cf83b14e8  x21 0000000000000de1  x22 b400007cf83b14f8  x23 b400007d984157d0
    x24 0000000000000001  x25 0000000000000de1  x26 0000007bd7538c98  x27 0000007bd7538e80
    x28 0000007bd7539368  x29 0000007bd7539fc0        
    lr  0000007bdb035f4c  sp  0000007bd7538c60  pc  0000007bdb035f50  pst 00000000a0000000
backtrace:
      #00 pc 00000000020f5f50  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #01 pc 00000000020f6868  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #02 pc 00000000020f6f64  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #03 pc 000000000210255c  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #04 pc 0000000002102230  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #05 pc 0000000002101e0c  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #06 pc 0000000002101d58  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #07 pc 00000000020f6994  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #08 pc 00000000020c580c  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #09 pc 00000000020b26d8  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #10 pc 00000000020b2624  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #11 pc 000000000214ae0c  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #12 pc 000000000214ad80  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #13 pc 000000000214ad44  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #14 pc 00000000021bd67c  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #15 pc 0000000001cdf09c  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #16 pc 0000000001cdf018  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #17 pc 0000000001ce6428  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #18 pc 00000000021480ec  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #19 pc 0000000001d077dc  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #20 pc 0000000001d0d364  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #21 pc 000000000001a064  /system/lib64/libutils.so (android::Looper::pollInner(int)+916) (BuildId: f2b5b5e5a774a0afb455e17c809c0ef0)
      #22 pc 0000000000019c68  /system/lib64/libutils.so (android::Looper::pollOnce(int, int*, int*, void**)+112) (BuildId: f2b5b5e5a774a0afb455e17c809c0ef0)     
      #23 pc 0000000000012d54  /system/lib64/libandroid.so (ALooper_pollOnce+100) (BuildId: ce2797b45eabdc2d6162cef362681456)
      #24 pc 0000000001d0d2ec  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #25 pc 0000000001d07728  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #26 pc 0000000001d0b5d0  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildI      #27 pc 0000000001d0b468  /data/app/~~q-X0rYRAelFdD4yROqE9VA==/com.example.flutter_image_filter_test-YjzDrfWuK-daCTV2_W021Q==/lib/arm64/libflutter.so (BuildId: 816a1a1c92b262314abb1fe2e9ff814ce75bf278)
      #28 pc 00000000000b0bd8  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+64) (BuildId: 564eb369899097e5c641e15844325264)
me/lib64/bionic/libc.so (__start_thread+64) (BuildId: 
564eb369899097e5c641e15844325264)
Lost connection to device.

Flutter Doctor output

Doctor output
[√] Flutter (Channel stable, 3.29.0, on Microsoft
    Windows [Version 10.0.19045.5487], locale ru-RU)  
[√] Android toolchain - develop for Android devices   
    (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual      
    Studio Build Tools 2022 17.6.5)
[√] Android Studio (version 2022.2)
[√] VS Code (version 1.97.2)
[√] Connected device (5 available)
[√] Network resources

• No issues found!

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listc: crashStack traces logged to the consolee: device-specificOnly manifests on certain devicese: impellerImpeller rendering backend issues and features requestsengineflutter/engine repository. See also e: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine teamtriaged-engineTriaged by Engine team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy