Michls posts in the mentioned topic should already answer your question I think.
In short:
CEF uses many threads and multiple processes. So in general you cannot assume that a variable is valid outside of a callback. That's the reason you get the SigSEVEV.
I'll try to explain more in-depth. The pattern is always the same - so I hope this will help you to better understand CEF and fpCEF:
You have the "VisitDomProc" - it's a helper method for VisitDom
VisitDom(TCefFastDomVisitor.Create(proc) as ICefDomVisitor);
As you can see, it creates a callback object, that wraps your callback function. You could have also passed a descendant of
TCefDomVisitorOwn to the VisitDom method.
That's the OOP abstraction layer of fpCEF. Now to the bottom CEF API layer - and how to find documentation:
Browser is the abstraction of
TCefBrowser.
A bit of scrolling explains what
MainFrame does:
// Returns the main (top-level) frame for the browser window.
get_main_frame: function(self: PCefBrowser): PCefFrame; cconv;
Ok, so we get a
TCefFrame.
So let's see what "VisitDom" does:
// Visit the DOM document. This function can only be called from the render
// process.
visit_dom: procedure(self: PCefFrame; visitor: PCefDomVisitor); cconv;
This tells us: we must be sure, that we are in the render process right now. If we are not, we need to use messages to communicate (please see the example in the referenced post).
Last step, see what
TCefDomVisitor does:
// Structure to implement for visiting the DOM. The functions of this structure
// will be called on the render process main thread.
and
// Method executed for visiting the DOM. The document object passed to this
// function represents a snapshot of the DOM at the time this function is
// executed. DOM objects are only valid for the scope of this function. Do not
// keep references to or attempt to access any DOM objects outside the scope
// of this function.
visit: procedure(self: PCefDomVisitor; document: PCefDomDocument); cconv;
Ok, it clearly says, that references are not valid outside. So we have to process everything inside the callback or implement a callback class, that holds the needed information.
Also this callback is called in the render process - so we need messages to pass any information back to our main process.
You now may ask: But I only programmed
one process / executable?
Well - see the process explorer, your application is started multiple times, having a different function each time.
For more information on this topic read:
https://bitbucket.org/chromiumembedded/cef/wiki/GeneralUsage.md#markdown-header-processes
As you can see, CEF is an complex beast - don't use it if you don't
really need a full-blown browser. Especially
not for HTML parsing - there are better solutions.