Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matrix4.scale causes an error on macOS. #338

Open
shingo-nakanishi opened this issue Dec 21, 2024 · 5 comments
Open

Matrix4.scale causes an error on macOS. #338

shingo-nakanishi opened this issue Dec 21, 2024 · 5 comments

Comments

@shingo-nakanishi
Copy link

shingo-nakanishi commented Dec 21, 2024

Reference: flame-engine/flame#3421

I encountered an error while trying to create a game using Flame. At first, I thought the issue was with Flame, but since I was able to reproduce it even without Flame, I'm posting about it.

code:

import 'package:flutter/material.dart';

void main() {
  runApp(_MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    final matrix = Matrix4.identity();
    matrix.scale(-1, 1);

    return const SizedBox();
  }
}

log:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following UnimplementedError was thrown building _MyApp(dirty):
UnimplementedError

The relevant error-causing widget was:
  _MyApp _MyApp:file:///project-folder/lib/main.dart:4:10

When the exception was thrown, this was the stack:
#0      Matrix4.scale (package:vector_math/src/vector_math_64/matrix4.dart:886:7)
#1      _MyApp.build (package:n_circle_page/main.dart:13:12)
#2      StatelessElement.build (package:flutter/src/widgets/framework.dart:5687:49)
#3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:5617:15)
#4      Element.rebuild (package:flutter/src/widgets/framework.dart:5333:7)
#5      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:5599:5)
#6      ComponentElement.mount (package:flutter/src/widgets/framework.dart:5593:5)
...     Normal element mounting (63 frames)
#69     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468:16)
#70     Element.updateChild (package:flutter/src/widgets/framework.dart:3963:18)
#71     _RawViewElement._updateChild (package:flutter/src/widgets/view.dart:441:16)
#72     _RawViewElement.mount (package:flutter/src/widgets/view.dart:464:5)
...     Normal element mounting (15 frames)
#87     Element.inflateWidget (package:flutter/src/widgets/framework.dart:4468:16)
#88     Element.updateChild (package:flutter/src/widgets/framework.dart:3963:18)
#89     RootElement._rebuild (package:flutter/src/widgets/binding.dart:1605:16)
#90     RootElement.mount (package:flutter/src/widgets/binding.dart:1574:5)
#91     RootWidget.attach.<anonymous closure> (package:flutter/src/widgets/binding.dart:1527:18)
#92     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:3038:19)
#93     RootWidget.attach (package:flutter/src/widgets/binding.dart:1526:13)
#94     WidgetsBinding.attachToBuildOwner (package:flutter/src/widgets/binding.dart:1265:27)
#95     WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:1247:5)
#96     WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:1233:7)
#100    _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
(elided 3 frames from class _Timer and dart:async-patch)
@spydon
Copy link
Collaborator

spydon commented Dec 21, 2024

It's because you're using ints, try using doubles instead.

@spydon
Copy link
Collaborator

spydon commented Dec 21, 2024

@shingo-nakanishi
Copy link
Author

Ah, it's created with the dynamic type.

Still, it's strange that it's working in Chrome.
Could JavaScript's type be affecting Dart as well? (That can't be the case, right?)

@shingo-nakanishi
Copy link
Author

shingo-nakanishi commented Dec 23, 2024

For now, it worked on macOS with the following:
matrix.scale(-1.0, 1)

@spydon
Copy link
Collaborator

spydon commented Dec 27, 2024

Could JavaScript's type be affecting Dart as well? (That can't be the case, right?)

Yes, it is since JS only have one type for both ints and doubles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants