It appears (at least for me), that HeadlessExample is broken. When I try to run it, I get a null pointer dereference, see the following backtrace in lldb:
(lldb) run
google.comProcess 62986 launched: '/Users/jhertz/a/chromium/src/out/a/headless_example' (arm64)
2022-08-25 21:47:08.701640-0400 headless_example[62986:25455662] [] [0x133030620] CVCGDisplayLink::setCurrentDisplay: 1
2022-08-25 21:47:08.701897-0400 headless_example[62986:25455662] [] [0x133030600] CVDisplayLinkCreateWithCGDisplays count: 1 [displayID[0]: 0x1] [CVCGDisplayLink: 0x133030620]
2022-08-25 21:47:08.701907-0400 headless_example[62986:25455662] [] [0x133030620] CVCGDisplayLink::finalize
2022-08-25 21:47:08.701910-0400 headless_example[62986:25455662] [] [0x133030620] CVDisplayLink::finalize
headless_example was compiled with optimization - stepping may behave oddly; variables may not be available.
Process 62986 stopped
* thread #1, name = 'CrBrowserMain', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x0000000100004b44 headless_example`OnHeadlessBrowserStarted(headless::HeadlessBrowser*) [inlined] HeadlessExample::HeadlessExample(this=0x000060000172a200, browser=0x0000000129e05260, web_contents=0x0000000000000000) at headless_example.cc:72:18 [opt]
69 : browser_(browser),
70 web_contents_(web_contents),
71 devtools_client_(headless::HeadlessDevToolsClient::Create()) {
-> 72 web_contents_->AddObserver(this);
73 }
74
75 HeadlessExample::~HeadlessExample() {
Target 0: (headless_example) stopped.
I am on the newest version of chromium (fbc0ddb4f4289d7a27676496c68780e1aa5d6607) at this time, and while I am writing a new headless module, I have not made any modifications to headless_example other than inserting a single line:
to stop it from complaining about not having a valid Seatbelt profile.