-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Browser reference held at Shutdown causing crash #1
Comments
Adding some research here: My debugging has lead me to CefLifeSpanHandler.DoClose() and learning more about the CEF destruction cycle. https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17668#p45915 but whenever i close the window, it calls CefShutdown.... hmmm.. We dont need to worry too much about the lifecycle apparently if we dont need to support the JS exit. apparently calling |
My take on this this
is saying that - at shutdown - ceflifespanhandler still has a reference to the browser.. so in the
this feels like progress. It feels like shutdown is working now after i explicitly dispose of the ceflifetimehandler. this would indicate the destructor is possible not being called.
but it also indicates that the destructor may not be called because something has a reference to this view?? |
https://www.magpcss.org/ceforum/viewtopic.php?f=10&t=17423 Found this indicating that to close the browser we need to remove the view. ^^
|
Hmm im wondering if this is the reason onbeforeclose is not called? after adding in the explicit call to inside chromely_mac.mm
i suspect the view isnt being removed properly from the heirachy? https://stackoverflow.com/questions/23428616/how-to-remove-view-from-superview
|
So i made some mods to make tracing the shutdown sequence possible across the stack through the same log output so i could exactly the sequence things were coming in on and i have gotten to the point where i no longer get a crash on shutdown.
i need todo more testing and then go over the changes and clean things up. but i feel like i am getting close! |
@captainjono this is great. So if I understand the findings so far, we need to:
On:
For Windows I have tried: public class DefaultLifeSpanHandler : CefLifeSpanHandler
{
protected override bool DoClose(CefBrowser browser)
{
this.Dispose(true);
return false;
}
} Is that correct? Does not seem to be working for 5.0. I see that you are creating a PR, that is great. Thanks. |
have u attempted to run this branch to verify what i am seeing? Although i am not gettting a crash anymore, i am seeing an interesting hang towards the end after If i run the app 10 times, most of the time it will do the above ^, but occasionally I will get a "successfully exited process" message and it doesnt hang. Ive tried adding in regarding windows, I have not attempted to validate how these fixes behave across OS's yet as i dont have any issues at all on windows - process exit is smooth and error free. My app is going to production soon only for mac, so this exit crash is becoming critical for me to solve and holds all my attention at the moment :) Im still integrating these fixes back into my codebase - i havnt successfully exited with my full app yet - im trying to chase down the reasons why https://www.magpcss.org/ceforum/viewtopic.php?f=14&t=17925 i think im and holding onto a reference somehow and am refactoring atm to isolate any cef refernces to a single point so i can dispose of them predictably. Do i need todo anything specific if i am using keyboard handlers? do i need to dispose of them at the time when i close the browser or is that supposed to be taken care of for me by chromely or it doesnt matter? |
@mattkol With the extra changes i have made around the cleanup process, i am now getting this error this when integrating back into my app here are some other errors and what i think there meaning is I saw this sometimes as i was debugging, im hoping by posting these it can trigger some thoughts My hunch is the current destruction sequence is causing all the components to fall apart instead of just closing the browser, releases the references then quitting the message loop. By the time quit is called, it feels like the subsystems are cleaning up resources and depending on what is on the stack depends on the luck at succeeding in the shutdown flow. |
@captainjono I am somehow losing track. In a previous comment I believe you were preparing a PR for the fix. So is this back to square one? I will be able to help over the weekend. So just run this repo - https://github.com/captainjono/Chromely/tree/xammac/Chromely.XamMac? |
@mattkol basically i fixed some aspects of the shutdown process, but not all of them. There is a threading issue somewhere that is occouring during the shutdown sequence and cleaning up objects somewhere that is causing libchromely and the main app to fall apart. Thats all i can really gather from the error codes so far. Depending on the CPU core count and the code in memory at the time the issue may present itself or not. to summarise:
|
Over the last week i have been able to perform extensive testing.
My next steps are to better understand who owns what:
|
I thought this was the original objective from the get-go - to have a replacement or parallel implementation of libchromely.dylib. If it is me, I will, because if it works well using XamMac (that has wider support) it is easier to retrofit libcrhomely.dylib or replace it entirely. On replacement as long as there is ownership/commitment going forward, I do not see why not. |
Thanks for the feedback. I wanted to re-write libchromely, but only if i had too (im currently under a very tight deadline and this is a large change to my system which has undergone extensive QA) :) I am diving deep into the auto-release pools + ARC at the moment. I think a double dispose or similiar may be happening. Maybeits an simple as reparenting or removing before destroy. Im thinking about the xam-mac implementation at the same time. Im not seeing anything complex going on. i found this code in on CEF forum that may be applicable
|
I have observed this too while working on Webview2. This is something we can explore. |
I have added a Im dealing with other errors now I think which are artefacts of other systems in my app. I'll continue my testing and grep the reply i got to the issue i posed. |
This PR resolves the issue |
With the sample application, when you close it will display a failure message because the call to CefRuntime.ShutDown() fails to execute because CefBrowser is being held in memory still.
My analysis is currently pointing towards the shutdown sequence not being correctly implemented and this only manifests on certain platforms in this way. As i starte debugging the shutdown sequence as per
https://magpcss.org/ceforum/viewtopic.php?f=6&t=17314
https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17696#p46124
https://www.magpcss.org/ceforum/viewtopic.php?f=6&t=17669
i came across this is the source code
which seems to indicate that CEF is not alerting the app at all the browser window has closed. My main suspect so far is the messageloop not draining correctly, I am in the process of trying different ways to wait, post delay task. etc to see if i can find a combo that works.
im experimenting in this branch
https://github.com/captainjono/Chromely/tree/xammac-fix-shutdown
not there yet... lots of leads
cefsharp/CefSharp#3047
chromelyapps#237
https://magpcss.org/ceforum/viewtopic.php?f=6&t=17314
The text was updated successfully, but these errors were encountered: