-
Notifications
You must be signed in to change notification settings - Fork 38
Description
Title
Release build crash caused by runtimeType.toString() type checks (minification issue)
Body
### Description
In release builds, Dart minifies class names (for example `Vector3` becomes something like `aU`).
The package currently checks types using `runtimeType.toString()`, which breaks in release mode and causes runtime crashes.
Example problematic code in `property_binding.dart`:
```dart
if (["Color", "Vector3", "Quaternion"]
.contains(nodeProperty.runtimeType.toString()))This works in debug/profile builds, but in release builds class names are minified, so the check fails.
As a result, Vector3 / Quaternion objects can be written directly into numeric buffers.
Later _lerp() tries to treat them as num, causing errors like:
Vector3 is not a subtype of num
PropertyMixer._lerp
AnimationMixer.update
This affects:
- Flutter web release builds
- Flutter web WASM builds
- dart2js optimized builds
Debug mode works fine, which makes the issue difficult to diagnose.
Root Cause
Using runtimeType.toString() for type checking is not safe in release builds because Dart minifies class names.
Suggested Fix
Replace string comparison with proper type checks using is:
if (nodeProperty is Color ||
nodeProperty is Vector3 ||
nodeProperty is Quaternion) {This fix resolves the crash in release builds and works correctly across debug/profile/release.
Environment
- Flutter: stable (3.x)
- Platform: Web (release & wasm)
- Package: three_js_animations
- Browser: Chrome, Safari
Notes
After applying this fix locally, release builds run correctly on Chrome and Safari without crashes.