tryphotino/photino.Native

Opening multiple windows causes crash on Linux

Closed this issue · 5 comments

Hi there folks, I was trying to combine an Avalonia linux app (https://avaloniaui.net) and use Photino as an embedded browser. I can start one instance of the Photino window and it works fine. However, when I close the window and try to open a new one, the entire app crashes with no stack trace. I've debugged the issue to be something in the C++ native Linux code, but all my attempts at solving the issue in C++ have not been successful. I'd greatly appreciate any ideas you may have in fixing this. Thanks for the great work!

Hi @RatikKapoor. Thank you for the kind words. We have not worked with Avalonia, but are interested in tracking this down for you as we're working to get a new 2.0 version tested and ready and would like to include all the fixes we can. Can you tell us which Linux distro you're using and if you're using Photino.NET or Photino.Blazor? So that we can try to reproduce.

Hi @MikeYeager apologies for the late reply. My specs are as follows:

System: Ubuntu 20.04 VM
Version: Photino.NET

I've managed to isolate how to repro the issue. Firstly, if I'm not running the Photino window on the main Avalonia thread, the second time I launch a window it will definitely crash. Secondly, if I call photinoWindow.Dispose() it will also crash second time around. I'm guessing here since IDisposable is implemented Dispose() is automatically called when the object falls out of scope. Calling it manually + a second time probably causes some null ref issue/segmentation fault in Photino second time it is launched.

I think the priority would be being able to launch a Photino window in a separate thread using Task.Run(...) reliably multiple times. If it helps I can push a sample where I can repro this issue and provide it to you!

This likely belongs in a separate issue but is an OnNavigated callback planned for the 2.0 release? This would be very useful in cases where the web control is redirected somewhere for google or SAML authentication and then we want to handle that redirect event in C#. Currently there's no event listener for when the browser is navigated. I have fully functional code for this in my local clone of this repo. I would be happy to PR this functionality and see it merged upstream here since this is a requirement for our use case :).

Thanks again for your help!

That makes sense. Photino needs to run on an STA thread, generally, the UI thread as it's a UI app. It also makes sense that calling Dispose() more than once is causing a crash. Dispose() will be different in V2. We'll try to add some code to prevent a crash if it's called multiple times. It's mainly being used in V1 to clean up child windows. We've now got the Windows portion of V2 working and almost ready for prime time. Linux and Mac coming next, but those tend to be a lot easier. Multi-window support on Windows was a major feature for V2 and required some big internal changes. It seems to be working very well now. The first window created runs the message loop and when that window is closed, all of the child windows close as well.

You can register custom schemes (other than http, https, file, etc.) and handlers in all versions, but we don't have an OnNavigated for standard schemes. I will look into adding handlers for standard schemes. It will have to be supported on all 3 native browser controls. Should be easy to hook up if it's supported. New features will be much easier to add in V2 if we can get it out the door.

Gotcha! This all sounds great, in that case I'll wait for a V2. If there's anything I can do to help test please let me know!

@RatikKapoor v2 of Photino has been released. Please give it a try and let us know if you see any issues.