gree / unity-webview

zlib License
2.23k stars 684 forks source link

Brotli Support #789

Open josemgmz opened 2 years ago

josemgmz commented 2 years ago

Hello,

I've been trying to get websites to improve download times and I've been trying to use brotli compression.

As I understand

for iOS: from version 11.0 - 15.1, support for brotli is already provided.

for android webview since chromium 98 version.

However, I have been able to read that this support is only for google chorome for the android Webview is an experimental flag in the WebView settings.

Can this flag be activated for all users using my version of webview?

https://stackoverflow.com/questions/65138909/how-to-enable-brotli-compression-on-android-system-webview

A greeting and thank you very much for the help.

KojiNakamaru commented 2 years ago

You can launch the dev ui with adb,

https://chromium.googlesource.com/chromium/src/+/HEAD/android_webview/docs/developer-ui.md#launch-via-adb

or by intent (the following is a diff for the sample app):

diff --git a/sample/Assets/Scripts/SampleWebView.cs b/sample/Assets/Scripts/SampleWebView.cs
index 9c3409a..ca6ec1c 100644
--- a/sample/Assets/Scripts/SampleWebView.cs
+++ b/sample/Assets/Scripts/SampleWebView.cs
@@ -242,5 +242,14 @@ public class SampleWebView : MonoBehaviour
             webViewObject.ClearCookies();
         }
         x += 90;
+
+        if (GUI.Button(new Rect(x, 10, 80, 80), "DEV")) {
+            var player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
+            var activity = player.GetStatic<AndroidJavaObject>("currentActivity");
+            var intent = new AndroidJavaObject("android.content.Intent");
+            intent.Call<AndroidJavaObject>("setAction", "com.android.webview.SHOW_DEV_UI");
+            activity.Call("startActivity", intent);
+        }
+        x += 90;
     }
 }

However, it seems to be difficult to enable the flag directly from the app.