Skip to content

Conversation

@amirghm
Copy link
Owner

@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 3 commits June 2, 2025 13:26
The import of `com.multiplatform.webview.util.KLogger` has been removed from `WebView.kt` as it was no longer in use.
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`.
@amirghm amirghm merged commit 8c08543 into main Jun 11, 2025
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