Skip to content

Linux/WSL: native WebView is hidden after first frame because _scheduleFrameVisibilityCheck() collapses it to 0x0 #22

Description

@faezzz92

I’m seeing a Linux rendering issue with webview_all_linux where the page loads successfully, JavaScript works, and the native GTK/WebKit view is initially given the correct size, but the widget is immediately hidden again.

Environment

  • webview_all_linux: 0.5.4
  • Flutter: 3.41.6
  • Linux target
  • Reproduced in WSL/WSLg on Ubuntu
  • Web content example: https://flutter.dev/

Actual behavior

  • onPageFinished fires
  • JavaScript can read the DOM successfully
  • GTK allocates the native view with the correct size
  • then the plugin sends another frame update with width=0, height=0, visible=false
    result: webview stays blank even though the page is loaded

Expected behavior
Once the native Linux webview has a valid frame and is attached, it should remain visible until:

  • its geometry changes
  • it is detached
  • it is disposed
    It should not be hidden just because the Flutter placeholder did not repaint in the next frame.

Relevant logs

webview_all_linux[1]: setFrame x=0 y=0 w=1280 h=636 visible=1
webview_all_linux[1]: allocated x=0 y=0 w=1280 h=636 visible=1 mapped=1
webview_all_linux[1]: setFrame x=0 y=0 w=0 h=0 visible=0

At the same time, page load still completes:

Finished https://flutter.dev/
DOM state url=https://flutter.dev/ ready=complete title=Flutter - Build apps for any screen bodyLength=3290.0 bg=rgb(255, 255, 255)

So the issue is not page loading; it is the native view being hidden after attach.

Root cause
The problem appears to be in _LinuxPlatformWebViewState inside lib/src/linux_webview_controller.dart.

The _scheduleFrameVisibilityCheck() watchdog hides the native view whenever the Flutter placeholder is not painted in a frame:

if (!_paintedThisFrame && _attached) {
  _pushRect(Rect.zero, visible: false);
}

For mostly static layouts, this is incorrect. The placeholder does not need to repaint every frame for the native webview to remain valid.

Workaround
I locally removed _scheduleFrameVisibilityCheck() and kept visibility updates only from:

  • _handlePaint() for geometry changes
  • detach() / dispose() for hiding
    After that change, the Linux webview rendered correctly.

Suggested fix
Remove or relax the per-frame visibility watchdog so the native webview is not collapsed to 0x0 just because no Flutter repaint happened in the following frame.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions