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

javascriptRuntime.dispose() error #153

Open
zhouxiaofu opened this issue Jun 25, 2024 · 1 comment
Open

javascriptRuntime.dispose() error #153

zhouxiaofu opened this issue Jun 25, 2024 · 1 comment

Comments

@zhouxiaofu
Copy link

version: flutter_js: ^0.8.1

demo

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late JavascriptRuntime javascriptRuntime;

  @override
  void initState() {
    super.initState();
    javascriptRuntime = getJavascriptRuntime();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FilledButton(
                onPressed: () {
                  JsEvalResult jsEvalResult = javascriptRuntime.evaluate("2 + 3");
                  debugPrint('jsEvalResult: ${jsEvalResult.stringResult} ${jsEvalResult.isError}');
                  javascriptRuntime.dispose();

                  javascriptRuntime = getJavascriptRuntime();
                },
                child: const Text("test"))
          ],
        ),
      ),
    );
  }
}

error

V/AudioManager( 3607): querySoundEffectsEnabled...
I/flutter ( 3607): jsEvalResult: 5 false
I/flutter ( 3607): reference leak:
I/flutter ( 3607):     ADDR	REF	TYPE	PROP
I/flutter ( 3607):   840208106	1	_JSFunction	(key, val) => { this[key] = val; } ...
I/flutter ( 3607):   1027286156	1	_JSFunction	function XMLHttpRequest() { ...
I/flutter ( 3607):   153620279	1	_JSFunction	function FLUTTER_NATIVEJS_MakeQuerablePromise(promise) { ...
I/flutter ( 3607): #0      new JSError (package:flutter_js/quickjs/object.dart:92:41)
I/flutter ( 3607): #1      QuickJsRuntime2.close (package:flutter_js/quickjs/quickjs_runtime2.dart:148:13)
I/flutter ( 3607): #2      QuickJsRuntime2.dispose (package:flutter_js/quickjs/quickjs_runtime2.dart:217:7)
I/flutter ( 3607): #3      _MyHomePageState.build.<anonymous closure> (package:js_demo/main.dart:58:37)
I/flutter ( 3607): #4      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1171:21)
I/flutter ( 3607): #5      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:344:24)
I/flutter ( 3607): #6      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:652:11)
I/flutter ( 3607): #7      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:309:5)
I/flutter ( 3607): #8      BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/
@rhyttr
Copy link

rhyttr commented Jul 11, 2024

Same error:

flutter: reference leak:
    ADDR	REF	TYPE	PROP
  1029104943	1	_JSFunction	(key, val) => { this[key] = val; } ...
  472009285	1	_JSFunction	function XMLHttpRequest() { ...
  531664568	1	_JSFunction	function FLUTTER_NATIVEJS_MakeQuerablePromise(promise) { ...
#0      new JSError                           package:flutter_js/quickjs/object.dart:92
#1      QuickJsRuntime2.close         package:flutter_js/quickjs/quickjs_runtime2.dart:148
#2      QuickJsRuntime2.dispose     package:flutter_js/quickjs/quickjs_runtime2.dart:217

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