Git Product home page Git Product logo

Comments (12)

a7ul avatar a7ul commented on May 14, 2024

Hi @intrnl
I tried the steps you suggested (even manually ran global.gc()) for about half an hour. And the app didnt crash. Is there anything more that you are doing in your app?

Also. the steps suggested to solve this might not have any effect.

(global as any)._reconcile = reconciler;

This is because reconciler is aleady in the module.exports of nodejs which means it wont be garbage collected at all.

Do you have an app source which I can clone and check ?

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

Also, it would be amazing if you can check this with latest nodegui and react nodegui versions aswell

from react-nodegui.

intrnl avatar intrnl commented on May 14, 2024

Tested on latest NodeGUI and React NodeGUI, it still happens.

I've made an example repo with the global variable commented. The app still exits after a few seconds.

$ npm run build

> [email protected] build /home/intrnl/Documents/projects/nodegui-test
> webpack --mode=production --progress

... webpack build output ...

$ npm run start

> [email protected] start /home/intrnl/Documents/projects/nodegui-test
> qode --inspect ./dist/index.js

QApplication: invalid style override passed, ignoring it.
    Available styles: Windows, Fusion
Debugger listening on ws://127.0.0.1:9229/df7d2dd5-4648-49ab-b946-aafe3088a0b3
For help, see: https://nodejs.org/en/docs/inspector
Qt exited with 0

from react-nodegui.

elviosak avatar elviosak commented on May 14, 2024

tried the repo from @intrnl and got the same results, app closes after ~8 seconds, when i run npm run build and npm start (also with packaged appimage), but no problems with npm run dev and npm start

import React from 'react';
import { Renderer, Window, Text } from '@nodegui/react-nodegui';

class App extends React.Component {
  render () {
    return (
      <Window windowTitle='Test App'>
        <Text>Hello world!</Text>
      </Window>
    )
  }
}
Renderer.render(<App />)

trimmed the app a little bit more (removed hot) and the problem continued, but the proposed solution works

linux mint 19.2
node 12.13.1
npm 6.13.1

"@nodegui/nodegui": "^0.7.0",
"@nodegui/react-nodegui": "^0.3.0",

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

@slidinghotdog @intrnl Yep, I can confirm I can reproduce this issue.
Seems like webpack bundling is causing some issues here. Need to dig a bit more deep on why this happens.

Also can you try with

 <Window windowTitle='Test App'>
    <View>
        <Text>Hello world!</Text> 
     </View>
 </Window>

and see if you get the same result ?

from react-nodegui.

elviosak avatar elviosak commented on May 14, 2024

no changes with View, but these 2 examples didn't close:

class App extends React.Component {
  state = { count: 0 };
  increase = () => {
    this.setState({ count: this.state.count + 1 });
  };
  componentDidMount() {
    setInterval(this.increase, 1000);
  }
  render() {
    return (
      <Window windowTitle="Test App">
        <Text>{`Hello world! ${this.state.count}`}</Text>
      </Window>
    );
  }
}
class App extends React.Component {
  state = { count: 0 };
  increase = () => {
    this.setState({ count: this.state.count + 1 });
  };
  render() {
    return (
      <Window windowTitle="Test App">
        <Button on={{clicked:this.increase}}text={`Hello world! ${this.state.count}`}></Button>
      </Window>
    );
  }
}

it looks like if theres any listeners it won't get gc..

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

That explains why default demo example doesnt close. Thanks for the inputs! @slidinghotdog

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

Okay even adding a simple
setInterval(() => {}, 100000); at the end of any file.
Makes the process be alive!

Another test is

setTimeout(() => {
  console.log("times up!");
}, 14000);

This make allows the process to stay alive for 14 secs. and after that whenever I run global.gc()
via the debugger the app closes.

So my theory is that nodejs process thinks that there are no more instructions for it to execute and then it just closes of.
So whenever a event listener is added it stays alive since it thinks it needs to wait for an instruction.

So I am guessing its not the garbage collection but simply that nodejs thinks it doesnt have any more things to execute.

from react-nodegui.

elviosak avatar elviosak commented on May 14, 2024

@master-atul is there any downside if u add @intrnl solution on default config for the renderer?

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

No I dont think so actually. Let me run few more checks and see which solution to go with

from react-nodegui.

elviosak avatar elviosak commented on May 14, 2024

don't know if its a good idea, but if theres something useful to run u could also attach some default listener on mainwindow (when created or closed), or run entire app on listener after main window is created

from react-nodegui.

a7ul avatar a7ul commented on May 14, 2024

Released in https://github.com/nodegui/react-nodegui/releases/tag/v0.3.1

from react-nodegui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.