Is Brotli compression supported and can the internal web server be modified in capacitor to handle br?

Trying to load a Unity instance on Android via a webpage loaded with Capacitor and I am receiving the following error:

“Msg: Failed to parse binary data file (with “Content-Type: null”), because it is still brotli-compressed. It should have been uncompressed by the browser, but it was unable to do so since the web server provided the compressed content without specifying the HTTP Response Header “Content-Encoding: br” that would have informed the browser that decompression is needed. Please verify your web server hosting configuration to add the missing “Content-Encoding: br” HTTP Response Header.”

I’m not finding anything related to configuring the internal web server hosting configuration for content-encoding br.

Could someone point me to that or offer a suggestion on how to resolve this if possible?

I am not 100% clear on what you are trying to do but I would think whatever web server is serving the web page you are trying to load in Capacitor needs to set the Content-Encoding HTTP header.

I’ve got a html page with some script tags that load Unity. Some of them are .br ( brotli ) but they are failing using Capacitor and throwing the quoted error listed above.

I can’t seem to locate where to enable brotli compression for whatever server is baked inside Capacitor to get around this error and move forward.

So the HTML page you are talking about is compiled into the native app via Capacitor? What are the script tags doing loading Unity? Are they referencing external sources or local scripts also embedded into the native app via Capacitor?

I wouldn’t say Capacitor is running its own web server (I could be wrong :grin:). I do know it uses the native web views. On iOS, Capacitor uses WKWebView (source) and on Android the Android System WebView (source).

Hopefully someone else can chime in with more knowledge of Capacitor and whether what you are trying to do is possible. But, please answer the questions above so they have more details of what you are attempting to do.

If you included some links to Brotli resources in Capacitor, it’s not Capacitor that is “serving” the Brotli resources; it will be whatever webserver is hosting those resources.

Generally, I don’t think you want to link directly to .br; instead, you should link to the original file, and then let the hosting webserver automatically compress the request to the file.

It is compiled into the native app via Capacitor.

What I’m trying to do actually will work, if you do NOT use compression with brotli, Capacitor doesn’t throw any errors regarding compression.

This really is a Capacitor/setup configuration that I am just not able to find any documentation on modifying the server configuration to support Brotli compression unfortunately. These files are all local and not reaching out to external sources.

I appreciate your time and taking a look.

What’s the WebView version you are testing on?

Brotli has been disabled in the WebView until version 119, so it won’t work on previous versions, but should work on 119 and newer.

1 Like

I am using WebView 121.0.6167.164