tryphotino / photino.NET

https://tryphotino.io
Apache License 2.0
833 stars 68 forks source link

Can't run multiple Photino applications at once #188

Open cubedparadox opened 1 month ago

cubedparadox commented 1 month ago

I've recently noticed a pretty glaring issue with Photino - if one Photino app is already running, then all subsequent Photino windows will render a white screen.

Here's what happens if I launch the Photino Sample React app, followed by the Photino Sample TestBench app: explorer_sickcovlgz And here's what happens if I run then in the reverse order. explorer_FyBXNShDgl

I've tried a bunch of misc configuration stuff to try and work around this issue, but haven't found a good fix yet.

This occurs with the official Photino samples, my personal Photino-based project, and the VRChat Creator Companion, which is also built with Photino.

I'm filing this issue in the .NET project because that's where I've encountered it, but it's entirely possible it's a deeper Photino Native issue.

I'm testing on Windows 10, I'm happy to share additional system details and logs as needed.

cubedparadox commented 1 month ago

Additional Information: I am able to run two instances of the same Photino app, just not two different Photino apps. image

mksondej commented 3 weeks ago

(note: not a dev of this project)

Could not reproduce this in my simple tests (built same demo app twice but with different content and it worked fine) but if you feel that the port is the issue (which is possible) then this is the part that fails here on your environment:

https://github.com/tryphotino/photino.NET.Server/blob/0a545a0c07aaa1c1fb258c91163605fdf3bfc93d/Photino.NET.Server/PhotinoServer.NET.cs#L57

As a workaround and additional test you could swap the invocation of "CreateStaticFileServer" in your project to the variant that accepts the port parameter. In other words change this in your Program.cs:

        PhotinoServer
            .CreateStaticFileServer(args, out string baseUrl)
            .RunAsync();

to this:

        PhotinoServer
            .CreateStaticFileServer(args, 9000, 100, "wwwroot", out baseUrl)
            .RunAsync();

If that works your guess was right and we can dig further why that "first available port checking" logic fails on your end.

PS: Looking at that if (port > port + portRange) and that entire condition in the while loop someone must've had been in a hurry :)

PS2: Note that this PhotinoServer is completely optional and all it does is spin up a localhost asp.net web app to serve your static files from wwwroot. Take a look at the code, it doesn't even add any custom middlewares. In my own project I've completely replaced that part with my own asp.net app since I also wanted to have some http endpoints and stuff.

philippjbauer commented 1 week ago

@mksondej Thank you for the reply on this issue. @cubedparadox did this resolve your issue? We couldn't reproduce the issue either.