3

Electron (version 7.x) window crashing on ubuntu 18, 20 for showOpenDialogSync or showOpenDialog Below is my code

directorySelection = e => {
        const { onCustomPathUpdate } = this.props;
        const remote = window.require('electron').remote;
        const openDialog = remote.dialog.showOpenDialogSync || remote.dialog.showOpenDialog;
        var directory = openDialog({
            properties: ['openDirectory']
        });

        if (directory && directory.length) {
            onCustomPathUpdate(directory[0]);
        }
    };

<button onClick={this.directorySelection} type="button">Browse</button>

I am hosting React(16.8.4) application in Electron(7.x) window. I am using the above code for opening file explorer of ubuntu and it is crashing the application. Can anyone help to get it fixed?

The above code is working fine with Ubuntu version 16.

pareshm
  • 4,874
  • 5
  • 35
  • 53
  • At the time of writing the latest Electron version is 13.1.9, the version of Electron you're using (7.x) is 1 year old. Is there a reason why you want to keep the 7.x version? – Joshua Aug 13 '21 at 05:19
  • @Joshua Yes, as Software is deployed at the client's machine, and upgrading Electron to the latest version requires lots of changes so currently not affordable to do that. and everything is working fine except this. – pareshm Aug 13 '21 at 05:44
  • Please, can you review [this GitHub issue](https://github.com/electron/electron/issues/20380)? Probably not, but it may be related to your problem. Basically, it seems a problem related to the use of VS Code instead of a native terminal when running your code. I hope it helps. – jccampanero Aug 14 '21 at 22:13
  • @jccampanero thanks for the response But I am not running from vs code terminal and running from Ubuntu terminal itself But not working Its is working fine on 16 version But crashing in 18 n 20 – pareshm Aug 15 '21 at 02:23
  • Thank you very much for the feedback @pareshm. I am sorry that the information was not helpful. And pareshm, does the program report any errors that you think can be relevant? – jccampanero Aug 15 '21 at 14:08
  • @jccampanero there are no helpful logs – pareshm Aug 15 '21 at 14:53
  • I am sorry mate. I have been looking for some clues about the problem. I suppose the affected file is `file_dialog_gtk.cc`. [This is the 7.x version](https://github.com/electron/electron/blob/2e9d88a630f0f588e2c8d72733627aa09ae9bc7e/shell/browser/ui/file_dialog_gtk.cc). According to the [file history](https://github.com/electron/electron/commits/v13.1.9/shell/browser/ui/file_dialog_gtk.cc) I think perhaps the issue [fix: dialog DCHECK on Linux](https://github.com/electron/electron/pull/28534) can be related. It is a back port of [this other one](https://github.com/electron/electron/pull/28478) – jccampanero Aug 15 '21 at 14:59
  • which in turn closes [this bug](https://github.com/electron/electron/issues/27837), but I don't think it is related to your problem... – jccampanero Aug 15 '21 at 15:00
  • @jccampanero Thanks buddy for your help n support Will try upgrading electron if it can help me with minimal changes. Is still you find any alternative for this Of If I find I will update here Thanks for your support buddy.. – pareshm Aug 15 '21 at 15:06
  • You are welcome pareshm. I hope the upgrade work properly and you find a solution. I am sorry for haven't been of more help. Please, do not hesitate to post here or contact me if you think I can be of any help. – jccampanero Aug 15 '21 at 15:12
  • Not sure if `showOpenDialogSync` being async is an issue, you can try [this](https://stackoverflow.com/a/60192729/4012913), could you find anything helpful from the crash reports ? – Towkir Aug 15 '21 at 15:18
  • check this https://stackoverflow.com/questions/43991267/electron-open-file-directory-in-specific-application – Ali Momeni Aug 19 '21 at 08:35
  • @jccampanero I changed the node version to 10.16.3 and also upgraded the Electron version to 13+ and rebuild my UI code and tried, it solved the issue, no not able to replicate the issue After upgrading only the Electron version to 13+ it did not solve the problem, but keeping the node version to 10.16.3 and rebuild the UI code solved the issue what I guess. – pareshm Aug 26 '21 at 05:36
  • Hi @pareshm. Thank you very much for sharing the solution. I am very happy to hear that you were able to solve the problem. – jccampanero Aug 26 '21 at 10:28

0 Answers0