nmfisher / thermion

3D rendering toolkit for Dart and/or Flutter
https://thermion.dev
Apache License 2.0
114 stars 9 forks source link

Quickstart page is inaccurate to modern flutter #58

Open pgrwe opened 2 months ago

pgrwe commented 2 months ago

This is all based off the project defaults from flutter create on the master channel. I have native assets enable. I am on windows 11 and followed the directions outlined on the windows page.

small changes

_MyAppState is now _MyHomePageState and MyApp is now MyHomePage

initState() requires @override and super.initState()

Ran into this error in editor: image

thermion_examples issues

I also wasn't able to run the quickstart or example flutter projects in thermion_examples.

Target native_assets failed : error : Building native assets failed.

nmfisher commented 2 months ago

Thanks for the report. For your first point, I'll update the docs to match the quickstart project (I thought I already did that, but obviously not).

On your second point, can you try using the following dependencies in pubspec.yaml:

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.8
  thermion_flutter: ^0.1.1+10
dependency_overrides:
  native_toolchain_c:
    git:
      url: https://github.com/nmfisher/native.git
      path: pkgs/native_toolchain_c
      ref: windows_dll_fix```

then run:
```bash
flutter clean
flutter packages upgrade
flutter run -d windows
pgrwe commented 2 months ago
dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.8
  thermion_flutter: ^0.1.1+10

dependency_overrides:
  native_toolchain_c:
    git:
      url: https://github.com/nmfisher/native.git
      path: pkgs/native_toolchain_c
      ref: windows_dll_fix

Hmm I thought I had added this prior since its outlined on the windows page but adding it worked! The scene itself had a couple of issues but I was eventually able to get to this point:

image

The first couple times I tried running this project, the loading of models took an incredibly long time. I also had some issues where the program would crash but I haven't been able to replicate it consistently. Also after I close the flutter window (by clicking the x in the top right), an artifact is left behind (this happens consistently, though it usually doesn't last long):

image

nmfisher commented 2 months ago

The first couple times I tried running this project, the loading of models took an incredibly long time.

I noticed this when I was upgrading the Windows build to Filament v.1.51.2. For me, it only happened the first time I ran the project, all subsequent runs were fine. It may have just been a coincidence, but when I minimized/restored the window, that flushed the pipeline and rendered the asset straight away. I'll create another issue specifically for this (it feels like a shader compilation or upstream issue that may be fixed in newer Filament versions).

I also had some issues where the program would crash but I haven't been able to replicate it consistently.

The easiest way to trace the source of crashes is to open the project in Visual Studio (not VS Code). If you run flutter build windows, there is a quickstart.sln file under build/windows/x64, open that, then right-click the quickstart project in the right panel, click "Set as Start-up Project", then run/debug. If it crashes, it should give you a stacktrace. Take a screenshot and file it here.

Also after I close the flutter window (by clicking the x in the top right), an artifact is left behind (this happens consistently, though it usually doesn't last long):

This is expected - on Windows we create a separate window for rendering beneath the Flutter window. When you close the Flutter window, the rendering window doesn't close for a couple of seconds. It's less of an issue on release builds but it is something that should be addressed. This could be something you could contribute to - there's either a lifecycle hook on the Flutter side that indicates the application is about to close, or the HWND event on the parent window. Add a listener to either of these to destroy the backing window.