WKWebview returns an 'unsupported type' error on every single function after first success while other webview works flawlessly.

I'm working on a SwiftUI application that uses a couple different webviews in a tabview to render some mdx and codemirror editor.

The editor webview, the one that's much more complicated works as expected. Some errors appear in the console due to what I imagine is a race condition that I'll get around to fixing, but it works as expected.

The other webview which just renders a single, local html file to display a dead simple summary absolutely refuses to work. It first appears to work as expected (shows the same 'return type unsupported' error in the console though) on the initial request, but then refuses to process any JS functions for that particular webview. Even the functions themselves are being used between the two webviews, and they work as expected in the other. Even worse, when I copy and paste the generated JS code into the safari dev tools it works as expected, even in the broken webview.

I've spent almost 12 hours on this today so far, and have made zero progress. I've tried commenting out just about the entire website to narrow it down on the JS side without success, and I've done everything I can think of on the swift side.

To be transparent, I'm very new to Swift and SwiftUI, having only picked it up a few weeks ago, but I'm an experienced developer and every obvious solution fails to work.

From what I've gathered, this might have something to do with the first function call failing, despite the fact that it appears to work on the first function call, but then the javascript engine refusing to process additional requests. I'm not sure if that's the cause, but it certainly seems to make sense.

Is there a way to debug this more completely? Like I said, I'm very new to Swift and still missing neovim, so I'm still getting comfortable with the apple ecosystem of devtools, but I can't even figure out how to print out the return type since it fails before I'm able to inspect anything on the safari side

I did notice this error in the console as well, and I'm not quite sure what to make of it:

Error acquiring assertion: <Error Domain=RBSServiceErrorDomain Code=1 "((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))" UserInfo={NSLocalizedFailureReason=((target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.rendering AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.networking AND target is not running or doesn't have entitlement com.apple.developer.web-browser-engine.webcontent))}>

And as I was digging for that one, I just noticed this:

WebContent[32934] 0x102011208 - [webPageID=306] WebPage::runJavaScriptInFrameInScriptWorld: Request to run JavaScript failed with error SecurityError: The operation is insecure.

What would trigger a security warning for running javascript against a local file?

Any help is greatly appreciated... this is driving me crazy.

WKWebview returns an 'unsupported type' error on every single function after first success while other webview works flawlessly.
 
 
Q