Skip to content

Conversation

amirghm
Copy link
Contributor

@amirghm amirghm commented Jun 11, 2025

This update enhances WebView functionality across Android and Desktop platforms with the following improvements:

• Improved Zoom Support: Refines and synchronizes zoom behavior across Android and Desktop platforms for a consistent user experience.

•Android Sandbox Support via WebViewAssetLoader:
Introduces secure local file loading using the standard sandbox domain (https://appassets.androidplatform.net/app).
This eliminates CORS restrictions and enables full cookie support for asset-based content in Android WebView.

These changes improve compatibility with modern web standards and enhance the security and capability of local file loading.

amirghm added 2 commits June 11, 2025 19:28
This commit introduces several improvements and fixes related to local file loading and zoom behavior across platforms:

**Android:**
- Added `enableSandbox` and `sandboxSubdomain` options to `PlatformWebSettings.androidWebSettings`. When `enableSandbox` is true, WebView uses `WebViewAssetLoader` with an `InternalStoragePathHandler` to serve local files (assets/resources/internal storage) over secure virtual `https://` URLs. This improves security and compatibility with modern web features like cookies and Service Workers.
- The `user-scalable` viewport meta tag is now correctly set based on `state.webSettings.supportZoom`.
- Removed redundant `setSupportZoom` call as it's handled by the viewport meta tag.

**Desktop:**
- Increased the delay before loading HTML content in `DesktopWebView.loadHtml` to 500ms to allow more time for file operations, potentially improving reliability.
- When loading HTML data, the desktop WebView now initially loads `KCEFBrowser.BLANK_URI` and then injects the HTML content. This change is to ensure proper initialization before content loading.
- Adjusted the zoom level calculation in `WebEngineExt.kt` for desktop to better align with other platforms. The new formula is `(percentage - 100.0) / 25.0`.

**Common:**
- `WebViewNavigator.loadHtmlFile` now accepts a `readType: WebViewFileReadType` parameter to specify how the HTML file should be read (e.g., from assets or resources). This parameter is passed down to the platform-specific implementations.
- `IWebView.loadHtml` and its implementations are now suspend functions to accommodate asynchronous operations like file reading or network requests if needed in the future.

**Internal:**
- Added `InternalStoragePathHandler.kt` for Android to handle serving files from internal storage via `WebViewAssetLoader`.

**Build:**
- Incremented `VERSION_NAME` to `2.0.1`.
@KevinnZou KevinnZou merged commit f40b28a into KevinnZou:main Jun 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants