Skip to content

Conversation

@amirghm
Copy link
Owner

@amirghm amirghm commented May 27, 2025

This commit introduces several improvements to the desktop WebView implementation:

  • Increased delay for file loading: The delay before loading local HTML files (both from assets and Compose resources) has been increased from 200ms to 500ms. This provides more time for file extraction and setup, potentially improving reliability.
  • Error handling for HTML loading: Added e.printStackTrace() in the catch block of DesktopWebView.loadHtml for better debugging of HTML loading errors.
  • Unified content loading: Refactored WebView.kt to use a common wv.loadContent(content) call within the LaunchedEffect for all content types, simplifying the logic.
  • Refined Desktop WebView initialization:
    • The KCEFBrowser instance is now recreated if state.content changes, ensuring the browser is correctly initialized for different content types (e.g., when switching from URL to File).
    • WebViewFactoryParam for WebContent.File now passes param.requestContext to createBrowser.
    • state.webView and webViewJsBridge?.webView are now set within a LaunchedEffect dependent on desktopWebView to ensure they are assigned after the DesktopWebView instance is fully created.
  • Removed verbose logging: Removed some KLogger debug statements related to navigation events and disposal.
  • Standardized File import: Changed java.io.File to File for consistency.

This commit introduces several improvements to the desktop WebView implementation:

- **Increased delay for file loading:** The delay before loading local HTML files (both from assets and Compose resources) has been increased from 200ms to 500ms. This provides more time for file extraction and setup, potentially improving reliability.
- **Error handling for HTML loading:** Added `e.printStackTrace()` in the `catch` block of `DesktopWebView.loadHtml` for better debugging of HTML loading errors.
- **Unified content loading:** Refactored `WebView.kt` to use a common `wv.loadContent(content)` call within the `LaunchedEffect` for all content types, simplifying the logic.
- **Refined Desktop WebView initialization:**
    - The `KCEFBrowser` instance is now recreated if `state.content` changes, ensuring the browser is correctly initialized for different content types (e.g., when switching from URL to File).
    - `WebViewFactoryParam` for `WebContent.File` now passes `param.requestContext` to `createBrowser`.
    - `state.webView` and `webViewJsBridge?.webView` are now set within a `LaunchedEffect` dependent on `desktopWebView` to ensure they are assigned after the `DesktopWebView` instance is fully created.
- **Removed verbose logging:** Removed some KLogger debug statements related to navigation events and disposal.
- **Standardized File import:** Changed `java.io.File` to `File` for consistency.
Repository owner deleted a comment from restack-app bot May 27, 2025
@amirghm amirghm merged commit 5fb7fb0 into main May 27, 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