The browser can be disposed on another thread between the IsDisposed check and
reading CefBrowserWrapper::Browser, which then returns a null CefRefPtr. The
finalizer dereferenced it and the NullReferenceException on the finalizer
thread terminated the process.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Fix deferred client certificate selection reading freed memory
CefCertificateCallbackWrapper held the offered certificate list as
`const X509CertificateList&`, bound to a stack local built in
ClientAdapter::OnSelectClientCertificate. Once that handler returned the
list was destroyed, so calling Select() at any later point walked freed
memory and threw inside the thumbprint-matching loop, taking the host
process down with it.
CEF explicitly permits answering later. cef_request_handler.h says to
return true and call Select "either in this method or at a later time",
so a wrapper that outlives the handler has to own the list it selects
from. It now holds a heap-allocated copy, freed in the finalizer. A ref
class cannot contain a std::vector by value, hence the pointer. Copying
the vector copies the reference-counted CefX509Certificate pointers, and
those references are what keep the certificates alive.
This is the remaining half of #2948. The comment above the caller reads
"Create a copy of the vector in an attempt to fix#2948", and the copy is
indeed made - but it is then bound by reference, so it dies at the same
instant the original would have.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Remove the redundant certificate vector copy in ClientAdapter
The wrapper takes its own copy in its constructor, so the local copy added
by a51cdd37 in ClientAdapter::OnSelectClientCertificate is now pure
redundancy - two copies where one is needed. Pass `certificates` straight
through instead.
Also refreshes the comment on _certificateList, which described the caller's
stack local that this removes.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: John Hodnik <jhodnik@activu.com>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
* Core - Cancel pending tasks when browser crashed or v8 context gets released
* Use TrySetCanceled to cancel pending tasks
* Adjust test to use chrome://crash for simulating a crash
* Add tests for javascript callbacks
* Rename tests and add tests for calling Execute multiple times
* Move FramePendingTaskRepository to its own file
* Rename test to ShouldCancelAfterV8ContextChange
* Fix compile error on .NET Framework
* adjust ShouldTimeoutIfNavigationOccurs test which now throws a TaskCanceledException on navigation
* Implement AcceleratedPaintInfo so the shared texture can be used for accelerated rendering in a custom IRenderHandler.
* Make AcceleratedPaintInfo members get-only properties, set via constructor.
Add XML comments, based on CEF.
---------
Co-authored-by: Dennis de Bruijn <d.de.bruijn@tss.nl>
Return true and execute callback either
asynchronously or in this method to continue or cancel the download.
Return false to proceed with default handling (cancel with Alloy style,
download shelf with Chrome style).
* Upgrade minimum .Net version to 4.6.2
#4433
* Use TaskCreationOptions.RunContinuationsAsynchronously
- Now that min version is .Net 4.6.2 we can use RunContinuationsAsynchronously
- Remove some unused code
* Core - Improve ClientAdapter::GetBrowserWrapper logic
Simplify the logic
- For non popup return immediately (most common scenario)
- Check for IBrowser instance for matching popup
- Check for HasParent and return the browser Instance
- Return nullptr if no matching IBrowser wrapper found
* Core - ClientAdapter::OnFrameCreated called before OnAfterCreated
- The very first call to ClientAdapter::OnFrameCreated happens
before OnAfterCreated leaving us with a IBrowser instance that's null
Create an IBrowser instance that's scoped to the method call
* Core - ClientAdapter improve HasParent checks
- HasParent check has now been replaced with IsHostedBrowser
which has additional check to make sure the internal
IWebBrowser.Set* methods are only called for a IBrowser
instance that's directly associated with a ChromiumWebBrowser instance
This resolves issues with DevTools being opened for a popup hosted
in a ChromiumWebBrowser instance.
Related discussion https://github.com/cefsharp/CefSharp/discussions/4438
- When CEF added CefFrameManager support the lifespan of a frame changed, it's now possible for MainFrame/FocusedFrame
to be null when the browser is closed.
Issue #4368
Logs some basic information so we can see what type of ChromiumWebBrowser hasn't been closed
within as part of the xUnit tests.
* Meant for internal use and might be subject to change.
CEF is now using Chrome file dialogs on all platforms and runtimes, this brings a number of fixes and also some API changes.
- The selectedAcceptFilter filter arg has now been removed
- The CefFileDialogFlags enum has been removed as CEF no longer supports these options
This is a breaking change.
Issue #4110