After upgrading three_js from 0.0.7 to 0.3.0, my Flutter Web app crashes at startup with the following error:
TypeError: dart.global.glCanvas is not a function
Stack trace:
package:flutter_angle/webgl/wrapper_wasm.dart
package:flutter_angle/webgl/angle.dart
package:three_js_angle_renderer/three_viewer.dart
Root cause
It looks like flutter_angle expects the JavaScript file gles_bindings.js to be loaded in the browser, but it is not automatically injected anymore.
The function glCanvas() is defined inside:
flutter_angle/example/assets/gles_bindings.js
Without this file, Flutter Web crashes because window.glCanvas is undefined.
Temporary workaround
I fixed the issue manually by:
Copying:
.flutter/pub-cache/hosted/pub.dev/flutter_angle-0.4.0/example/assets/gles_bindings.js
into:
web/gles_bindings.js
Adding this line in web/index.html before flutter_bootstrap.js:
<script src="gles_bindings.js"></script>
After this change, the application works correctly again on Flutter Web.
Additional context
I upgraded because I needed the newer flutter_angle version to fix Android 16 KB page size compatibility warnings from Google Play Console.
Maybe the package could:
automatically inject the JS asset,
document the migration,
or expose a clearer setup step for Flutter Web.
Thanks!
After upgrading three_js from 0.0.7 to 0.3.0, my Flutter Web app crashes at startup with the following error:
TypeError: dart.global.glCanvas is not a function
Stack trace:
package:flutter_angle/webgl/wrapper_wasm.dart
package:flutter_angle/webgl/angle.dart
package:three_js_angle_renderer/three_viewer.dart
Root cause
It looks like flutter_angle expects the JavaScript file gles_bindings.js to be loaded in the browser, but it is not automatically injected anymore.
The function glCanvas() is defined inside:
flutter_angle/example/assets/gles_bindings.js
Without this file, Flutter Web crashes because window.glCanvas is undefined.
Temporary workaround
I fixed the issue manually by:
Copying:
.flutter/pub-cache/hosted/pub.dev/flutter_angle-0.4.0/example/assets/gles_bindings.js
into:
web/gles_bindings.js
<script src="gles_bindings.js"></script>Adding this line in web/index.html before flutter_bootstrap.js:
After this change, the application works correctly again on Flutter Web.
Additional context
I upgraded because I needed the newer flutter_angle version to fix Android 16 KB page size compatibility warnings from Google Play Console.
Maybe the package could:
automatically inject the JS asset,
document the migration,
or expose a clearer setup step for Flutter Web.
Thanks!