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

Hot restart on Android throws exception #53

Open
Hannnes1 opened this issue Jul 2, 2024 · 0 comments
Open

Hot restart on Android throws exception #53

Hannnes1 opened this issue Jul 2, 2024 · 0 comments

Comments

@Hannnes1
Copy link
Contributor

Hannnes1 commented Jul 2, 2024

Doing a hot restart on android throws the following exception:

E/flutter (18641): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(TEXTURE_EXISTS, Texture already exist. Make sure you call destroyTexture first, null, null)
E/flutter (18641): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
E/flutter (18641): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter (18641): <asynchronous suspension>
E/flutter (18641): #2      ThermionFlutterFFI.createTexture (package:thermion_flutter_ffi/thermion_flutter_ffi.dart:126:18)
E/flutter (18641): <asynchronous suspension>
E/flutter (18641): #3      _ThermionWidgetState.initState.<anonymous closure> (package:thermion_flutter/thermion/widgets/thermion_widget.dart:48:18)
E/flutter (18641): <asynchronous suspension>

During my limited investigation I found this issue, which I think is the reason: flutter/flutter#75528

Reproducible example:

import 'package:flutter/material.dart';
import 'package:thermion_flutter/thermion_flutter.dart';

void main() {
  runApp(const MainApp());
}

class MainApp extends StatefulWidget {
  const MainApp({super.key});

  @override
  State<MainApp> createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {
  ThermionViewer? _viewer;

  @override
  void initState() {
    super.initState();

    ThermionFlutterPlugin.createViewer().then((value) {
      _viewer = value;

      value.loadIbl('assets/custom_ibl.ktx');
      value.loadGlb('assets/duck.glb');

      value.setCameraPosition(0, 0, -1);

      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: _viewer == null
              ? const CircularProgressIndicator()
              : ThermionWidget(
                  viewer: _viewer!,
                ),
        ),
      ),
    );
  }
}
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

1 participant