Skip to content

Crash when upgrading to 0.3.0 - glCanvas is not a function #135

@anasza95

Description

@anasza95

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions