Sandboxing issue: HTMLViewer and sandbox

Html file is not displayed in HTMLViewer if the application is sandboxed. (If the application is not sandboxed, HTMLViewer displays the html file correctly.) Where might be a problem? Thank you for your help.

You pneed some plist entries maybe.

Where is the HTML file and how does the application load it? User drag it in, open dialog, path stored in preferences?

Thanks for the hint, I added this to the plist file but it does not work:
NSAllowsArbitraryLoadsInWebContent

The html file is in the user temporary folder, the file is ok, the sandboxed application reads it correctly, the messagebox displays it. However HTMLViewer does not display it. (The HTMLViewer in the sandboxed application does not even display an html string.)

I know that Apple have gotten more “Security” focused over time with the HTML Viewer.

I just wrote my own Help Viewer for App Wrapper (which is not Sandboxed) as help doesn’t work for everyone on Monterey, and dynamically generated content wouldn’t load images or allow the links to work until I was referencing an actual valid web page.

HTMLViewer1.loadPage( HTMLContent, actualExistingHTMLPage )

Somewhere on this forum are the declares that should also allow you to grant the HTMLViewer access to a specific folder, which you have to do when you load a page from a Sandboxed application, it MUST be a location that your application has access to, which doesn’t always include the temporary folder, the user cache folder or the application support folder (for your application) should be sufficient.

It’s late here and I’ve had a long day, so I’ll test out the Help Viewer in a Sandboxed application tomorrow and see what needs to be done to make it work (as I’ll need to roll my help viewer into my other applications at some point).

Maybe this can help:


wRender.HTMLViewer1.grantAccessToFolder(Data_FI)
wRender.HTMLViewer1.LoadPage(TA.Text, Data_FI)

wRender is a reference to a window where HTMLViewer1 resides.
Data_FI is a reference (temporary) where I saved the html created in a TextArea.
Nota to self: I do not saw code to delete that file; I do not saw “this file” (different file name) on my hard disk…

I think I have to thank Sam (once more) for that tip.

1 Like
1 Like

Sam, Emile and Rick - thanks a lot for the suggestions. I used the mentioned declares and even after grantAccessToFolder HTMLViewer does not display the html file if the application is sandboxed.
However, it seems that the problem is not in the file access because HTMLViewer does not even display an html string if the application is sandboxed: HTMLViewer.LoadPage(htmlString, nil)
If the application is not sandboxed, HTMLViewer displays the html file or the html string correctly.

As far as I know, you can’t pass Nil as the second argument. It should be something like:

HTMLViewer1.LoadPage(htmlContentString, FolderItem.TemporaryFile)

Unfortunately, it does not work neither.

If the application is not sandboxed, both of them display the content correctly:
HTMLViewer.LoadPage(htmlString, nil)
HTMLViewer.LoadPage(htmlString, FolderItem.TemporaryFile)

If the application is sandboxed, both of them do not dispaly anything:
HTMLViewer.LoadPage(htmlString, nil)
HTMLViewer.LoadPage(htmlString, FolderItem.TemporaryFile)

How did you get the file access set as Sam said? You shouldn’t be using Nil for that.

I think you should try set a var to SpecialFolder.Temporary and then request access to such folder,
Then create a dummy file there and pass its FolderItem as the second argument of LoadPage()

1 Like

We have had a similar issue in the Electron repository when sandboxing apps. The issue is CEF related in that case though… Bug has been active since 2017. Wonder if these are related?

He’s on a Mac, not using CEF.

The one person I know here, that IF it’s possible to make it work, get it done, is Sam.

The issue resides in WebKit within CEF. WebKit is still used on Mac also? (Haven’t fired my Mac up in 2 years :-))

WebKit is not CEF. Xojo, in Macs, does not use the Chromium engine.

From Chromium.org -

  • WebKit: Rendering engine is shared between Safari, Chromium, and all other WebKit-based browsers.

I used Sam’s declares (grantAccessToFolder) as described in the “New problem with HTMLViewer.LoadPage since Version 2020 R1” topic.

I did it:

  1. dim tempFolder as FolderItem = SpecialFolder.Temporary
  2. I requested the access with Sam’s declares: HTMLViewer.grantAccessToFolder(tempFolder)
  3. I created a dummy file in tempFolder
  4. HTMLViewer.LoadPage(htmlString, dummyFile)

Unfortunately, it does not work in the sandboxed application.

Someone, please, try to explain him what I tried and failed.

I have not enough knowledge to help you further.
I guess your only hope is Sam + Xojo.