Electron.NET icon indicating copy to clipboard operation
Electron.NET copied to clipboard

Application UI does not start on some laptops. No log or error

Open hemantsathe opened this issue 4 years ago • 18 comments

We have built an app using Electron.NET and ASP.NET on .Net 5. This app does not run on our client's laptop and on one more laptop but otherwise runs on developer/ non-developer machines and VMs otherwise.

We have found that the async call to CreateBrowserWindowAsync call fails on these machines but it does not throw any error. We have wrapped it in try catch, assigned the call to a task and awaited the task. However, the task simply does not launch or complete at all. There is no log available. Nothing in the event viewer as well.

Here is the code snippet

            try
            {
                _logger.LogInformation("Attempting to launch the window asynchronously!");
               // This async call does not launch or probably never returns.
                var createWindowTask = Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions
                {
                    Title = string.Empty,
                    WebPreferences = new WebPreferences
                    {
                        NodeIntegration = true,
                        DevTools = true,
                        AllowRunningInsecureContent = true,
                        EnableRemoteModule = true
                    }
                });
                var browserWindow = await createWindowTask;
                if(createWindowTask.IsCanceled) _logger.LogInformation("Window creation is cancelled");
                if(createWindowTask.IsCompleted) _logger.LogInformation($"Window creation task completed with status : {createWindowTask.Status}");
                if (createWindowTask.Exception != null)
                {
                    _logger.LogError($"Exception in creating App Window: {createWindowTask.Exception.Message}");
                    var innerExceptions = createWindowTask.Exception.InnerExceptions;
                    if (innerExceptions?.Count > 0)
                    {
                        foreach (var ex in innerExceptions)
                        {
                            _logger.LogError($"Inner Exception: {ex.Message}");
                        }
                    }
                    _logger.LogError($"No further Inner Exceptions");
                }
                _logger.LogInformation("Initializing App - Electron Bootstrap- Menu Bar init - Begin");

                browserWindow.SetMenuBarVisibility(false);

                _logger.LogInformation("Initializing App - Electron Bootstrap- Menu Bar init - End");


                _logger.LogInformation("Initializing App - Electron Bootstrap- clear cache - Begin");

                await browserWindow.WebContents.Session.ClearCacheAsync();

                _logger.LogInformation("Initializing App - Electron Bootstrap- clear cache - End");


                _logger.LogInformation("Initializing App - Electron Bootstrap- Init browser window show action - Begin");

                browserWindow.OnReadyToShow += () => browserWindow.Show();

                _logger.LogInformation("Initializing App - Electron Bootstrap- Init browser window show action - End");
            }
            catch (Exception ex)
            {
                _logger.LogCritical($"Error when starting the App. \n\tSource: {ex.Source}\n\tMessage : {ex.Message}\n\tInner Exception:{ex.InnerException?.Message}");
            }

In the event viewer though we have found that the call to AppName.exe does not get called with --type=renderer parameter on these machine whereas on the other machines it does call with renderer parameter and the UI is visible.

We are not able to trace the root cause and as this is not running on client's laptop, he is likely to cancel the project.

What we expect is to at least be able to get the root cause of the issue.

TIA

Hemant

hemantsathe avatar Nov 09 '21 18:11 hemantsathe

@GregorBiswanger - Please help or assign this to someone. Thanks.

hemantsathe avatar Nov 15 '21 12:11 hemantsathe

Any details about the devices in question (os/model)? I have noticed that when debugging on my m1 mac it will occasionally open the app but not launch the main window. It gets stuck after it prints ASP.NET Core Port: 8001 and doesn't get to the point where it would print stdout: Use Electron Port: 8000. No errors are printed, even with /watch. I havent been able to get that to happen in any builds, however. Just with electronize /start.

bman46 avatar Nov 21 '21 04:11 bman46

I can confirm that I get the same behavior on Windows with .net 6/13.5.1. Another project using .net 5 and version 9 of Electron.NET works fine.

ziadakiki avatar Nov 21 '21 18:11 ziadakiki

I have the same situation. I can start it from visual studio by invoking electronize /start, but after building it using electronize /build which succeeds, the application starts, but without a window. As @ziadakiki already mentioned, I also think, that this can be in relation to a .NET 6 SDK installation, but I really need a fix or workaround for this.

trdsolutions avatar Nov 29 '21 07:11 trdsolutions

Experience the same thing, in some laptos wont start

UicoCastol avatar Nov 29 '21 21:11 UicoCastol

Can I get a list of OS & Languages (Default os language that is) that you all are experiencing this on as well as your build properties...i.e. whats passed to electronize build

Also... do the machines experiencing this issue have the .net 5 runtime installed on them? you can determine whats installed on the machines by running dotnet --info

danatcofo avatar Dec 07 '21 16:12 danatcofo

Hello,

  • Windows 11 Home [Version 10.0.22000.348], English
  • Nothing passed to electronize build
  • .net 5 (runtime only) coexists on the machine with .net 6 (sdk)

ziadakiki avatar Dec 07 '21 21:12 ziadakiki

Ok... so we can try a something here to hopefully see whats happening... Assuming that you didn't change any ports...

  • Start the electron application
  • Open Powershell and execute the following script
electronapp/bin > appname.exe /electronPort=8000 /electronWebPort=8001

obviously substituting the appname.exe for your application name. If you did change the default ports, updated accordingly.

Observe the output...

One of the issues that we have an open PR for #592 is that we don't capture the error output from the net core application, we only capture the default output. This is a workaround to see what errors may be thrown that are not captured during startup.

danatcofo avatar Dec 07 '21 22:12 danatcofo

Here's my console output when running this command:

Use Electron Port: 8000
info: Microsoft.Hosting.Lifetime[14]
      Now listening on: http://localhost:8001
ASP.NET Core host has fully started.
info: Microsoft.Hosting.Lifetime[0]
      Application started. Press Ctrl+C to shut down.
info: Microsoft.Hosting.Lifetime[0]
      Hosting environment: Production
info: Microsoft.Hosting.Lifetime[0]
      Content root path: ******\bin\Debug\net6.0\

Nothing else happens.

ziadakiki avatar Dec 08 '21 16:12 ziadakiki

hmm... what I see is that it thinks its a net6 app when it should be a net5 app, we haven't added support for ElectronNET to run under net6

Can you try building with the following command. electronize build /PublishReadyToRun true. What this should do is package up all the dependencies such that there is no external dependencies on having any sdks or runtimes installed on the machines installed to.

danatcofo avatar Dec 08 '21 16:12 danatcofo

we haven't added support for ElectronNET to run under net6

I guess this should be the issue. I'm targeting .net 6. I tried building with the mentioned command, it generated an installer. After installing, I tried to open the app and it did not work. Any timeframe for the .net 6 support? Is it something I can help with?

ziadakiki avatar Dec 08 '21 16:12 ziadakiki

I don't think we have a ticket open for it at the moment... BUT it is an open source project and if you wanted to do the work of creating the support go ahead. I think in the past we've just pushed the version ahead and dropped support for older versions of .net. Personally I'd rather NOT do that as its very disruptive for consumers.

danatcofo avatar Dec 08 '21 16:12 danatcofo

NET6 support added in #636

danatcofo avatar Dec 09 '21 21:12 danatcofo

Hi @danatcofo that's great. So the issue turned out to be solely from the System.Drawing.Color namespace?

ziadakiki avatar Dec 09 '21 21:12 ziadakiki

Its likely due to the System.Drawing.Common dependency in ElectronNET.API and the v5 dependencies thereof... Feel free to pull a local copy of the PR source and build off of that. You'll have to add a local nuget package source to pick up the API reference generated when you build the source.

danatcofo avatar Dec 09 '21 22:12 danatcofo

Apologies for a late response on that. We are using Windows 10 with .Net 5. This is in a large enterprise with their standard image. The app runs fine on most devices but fails on two laptops without any trace of issue. Total silence. Since this was only on end user machine we did not have much tooling support either.

Our client was upset with this and felt it is a supportability issue as his users are spread out across globe and not too many in number. We finally chose to upgrade our old WPF application to .Net 5/6 and dropped the complete Electron.Net port. I felt sad for this but we could not promise anything on Electron.Net.

hemantsathe avatar Dec 10 '21 06:12 hemantsathe

@hemantsathe with such a wide distribution you might have been hit by an issue in .net around OS language default naming practices. We hit an issue with Italian language where it wouldn't start because it couldn't find the .net5 runtime. Rather than looking under the language specific location of Programmi\.... it was looking under the English language location of Program Files\.... In order to fix that I had to update our build script to pass in /PublishReadyToRun true as a parameter. I describe the issue in #630

danatcofo avatar Dec 10 '21 14:12 danatcofo

@hemantsathe et al. I had a very similar issue recently where my electron.net was working for everyone but 2 machines. It turned out...localhost was being sent to their enterprise proxy for some dumb reason. The fix was to simply was for the user to add the environment variable "NO_PROXY" and that localhost is in its value.

image

schaveyt avatar Dec 27 '21 20:12 schaveyt

Hi everyone,

I created a new app by following the "Usage" instructions on the GitHub page.

When I start the application it shows that it is running without errors in the terminal. The app's icon appears in the menu bar. But the application window is not displayed. I colonized the API Demos and the same happened. Please watch the Loom video recording.

  • https://www.loom.com/share/f525792be717451c91b49d8df18507bb

Computer specs:

  • MacBook Pro 2020, Intel Chipset.
  • Monterey 12.5

Software features:

  • Electron.NET Tools (13.5.1+186209486130f63c0e267c912d2e7f08ba7ab0d9)
  • Project Home: https://github.com/ElectronNET/Electron.NET
  • version Displays the ElectronNET.CLI version
  • .NET 5.0
  • (Also, .NET 6.0 is installed on my computer. Visual Studio is installed.)

Thanks,

mcyenikoylu avatar Sep 23 '22 16:09 mcyenikoylu

@hemantsathe et al. I had a very similar issue recently where my electron.net was working for everyone but 2 machines. It turned out...localhost was being sent to their enterprise proxy for some dumb reason. The fix was to simply was for the user to add the environment variable "NO_PROXY" and that localhost is in its value.

image

That could very well be the issue. The customer environment doesn't have easy proxy setting for non devs.

hemantsathe avatar Oct 16 '22 14:10 hemantsathe

🎉🚀 New Electron.NET version 23.6.1 released 🚀🎉

With native Electron 23 and .NET 6 support. Your problem should be fixed here. If you continue to have the problem, please let us know. Please note the correct updating of your API & CLI. Info in the README. Have fun!

GregorBiswanger avatar Mar 28 '23 20:03 GregorBiswanger

Hi, I tried to run the project found here https://github.com/ElectronNET/Electron.NET (src/ElectronNET.WebApp) using electronize start. The app opens in the task bar and I can see a splash screen but it remains stuck there.

OS: macOS Ventura - Version 13.3.1 (22E261)

dotnet --info: .NET SDK (reflecting any global.json): Version: 6.0.406 Commit: 2988897946

Runtime Environment: OS Name: Mac OS X OS Version: 13.3 OS Platform: Darwin RID: osx-arm64 Base Path: /usr/local/share/dotnet/sdk/6.0.406/

global.json file: Not found

Host: Version: 6.0.14 Architecture: arm64 Commit: 2a90daa2cc

.NET SDKs installed: 6.0.406 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.14 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

node --version v18.14.1

electronize version ElectronNET.CLI Version: 23.6.1.0

dotnet tool list -g

Package Id Version Commands electronnet.cli 23.6.1 electronize x 6.0.11 x

I have a colleague who runs the same configuration on Windows and for him it works, and another one who runs it on macOS (same as me) and his also works. I am the only one who can't use electronize on his machine. Could somebody provide some guidance?

The command that I runned and its output:

electronize start Start Electron Desktop Application... Arguments:

dotnet publish -r osx-x64 -c "Debug" --output "/Users/abuga/Electron.NET/src/ElectronNET.WebApp/obj/Host/bin" /p:PublishReadyToRun=true /p:PublishSingleFile=true --no-self-contained MSBuild version 17.3.2+561848881 for .NET Determining projects to restore... All projects are up-to-date for restore. ElectronNET.API -> /Users/abuga/Electron.NET/src/ElectronNET.API/bin/Debug/net6.0/ElectronNET.API.dll /tmp/MSBuildTemproot/tmp8d562b9729744b348586e7da3e313089.exec.cmd: line 2: /Users/abuga/Electron.NET/src/ElectronNET.API/devCleanup.sh: Permission denied ElectronNET.WebApp -> /Users/abuga/Electron.NET/src/ElectronNET.WebApp/bin/Debug/net6.0/osx-x64/ElectronNET.WebApp.dll ElectronNET.WebApp -> /Users/abuga/Electron.NET/src/ElectronNET.WebApp/obj/Host/bin/

node_modules missing in: /Users/abuga/Electron.NET/src/ElectronNET.WebApp/obj/Host/node_modules Start npm install... npm install

up to date, audited 153 packages in 509ms

22 packages are looking for funding run npm fund for details

found 0 vulnerabilities

ElectronHostHook handling started... Start npm install for typescript & hosthooks... npm install

added 118 packages, and audited 119 packages in 757ms

6 packages are looking for funding run npm fund for details

3 vulnerabilities (2 low, 1 high)

To address issues that do not require attention, run: npm audit fix

To address all issues (including breaking changes), run: npm audit fix --force

Run npm audit for details.

npx tsc -p ../../ElectronHostHook ../../ElectronHostHook/connector.ts(2,33): error TS2503: Cannot find namespace 'SocketIO'. ../../ElectronHostHook/excelCreator.ts(1,24): error TS2307: Cannot find module 'exceljs' or its corresponding type declarations. ../../ElectronHostHook/excelCreator.ts(2,37): error TS2307: Cannot find module 'exceljs' or its corresponding type declarations. ../../ElectronHostHook/index.ts(7,25): error TS2503: Cannot find namespace 'SocketIO'.

Invoke electron - in dir: /Users/abuga/Electron.NET/src/ElectronNET.WebApp/obj/Host/node_modules/.bin ./electron "../../main.js" Electron Socket IO Port: 8000 Electron Socket started on port 8000 at 127.0.0.1 ASP.NET Core Port: 8001 ---STUCK HERE image

abuga-bd avatar May 05 '23 14:05 abuga-bd

Hi, it seems the issue was me using .net 6 sdk for macos arm64 for the "electronize start" command published on osx-x64. I switched to .net 6 sdk macos x64 and now it's working fine.

abuga-bd avatar May 06 '23 10:05 abuga-bd