98teg / NativeDialogs

Native Dialogs is a plugin for Godot that allows you to interact with OS-specific dialogs, such as notifications, messages and file dialogs.
MIT License
156 stars 8 forks source link

Game window freezes upon closing #18

Open tjp1205 opened 1 year ago

tjp1205 commented 1 year ago

Great work first of all!

I have implemented NatvieDialogs in my game and everything works well until I try to close the game window. Every time when i close it, it will freeze and become unresponsive, sometimes closing after half a minute, sometimes it just won't close at all. I was able to replicate this issue on the demo project in the main.tscn scene as well as all other native_dialog scenes.

I am on Windows 10 22H219045.2728

98teg commented 1 year ago

Hi, thank you for your kind words! So far this is the process that I have followed in order to replicate this issue:

  1. Open NativeFileDialog.
  2. Try closing the game window without having closed NativeFileDialog.
  3. The game window won't close until I close NativeFileDialog.

I have also noticed that the hide button in the demo project doesn't work. These two issues only seem to happen with NativeFileDialog, the other nodes work fine. This also only seems to happen in Windows, I have tried it in Ubuntu and it seems to be working fine there.

Does this align with your issue or did you follow another series of steps?

tjp1205 commented 1 year ago

Yes, I have noticed the same issues with NativeFileDialog regarding Hide() while it's open. On top of that, the freezing issue I mentioned earlier occurred in all scenes under the demo/scenes folder. Steps to replicate:

  1. Run a NativeDialog scene, for example the native_confirmation scene
  2. Close the game window onces it's loaded, note that it doesnt matter if my press any of the buttons in the scene, as long as I click the close button the game would freeze
98teg commented 1 year ago

I'm unable to reproduce the issue you are describing. Those scenes work fine for me. Could you check if this still happens even if you delete the _NativeConfirmationDialog node of the scene? It is weird that your game is affected by this plugin without even opening the dialog.

tjp1205 commented 1 year ago

I seem to have noticed a pattern to replicate the issue. When I first opened the project, closing game windows does not have any lag, then as time progresses and as I have run numerous test scenes and closed them, the time taken to close the windows begin to increase. Would it be possible that some native Windows resources have been accumulating in the background and were not freed upon closing up the game?

As a background note, I am developing the main program in C#. Since there's no way to call the NativeFileDialog class directly from C#, I have created a gdscript wrapper such that I can call NativeFileDialog from C# via the gd wrapper with some thing like this:

  1. Inside the C# class:
    
    private Node _nativeFileDialog;

public void ClearFilter() => _nativeFileDialog.Call(nameof(ClearFilter));

2. Inside the gdscript wrapper:
``` gdscript
@onready var native_file_dialog: NativeFileDialog = $NativeFileDialog

func ClearFilter():
    native_file_dialog.clear_filters();

Then, as I was debugging in vscode, I would get this error from the gdextension as I close down the game window:

ERROR: Attempt to unregister class 'NativeAcceptDialog' while other extension classes inherit from it.
   at: (core/extension/gdextension.cpp:382)