#8811·kivy

Cross-platform `WebView` Implementation with off-screen rendering and OpenGL texture upload

Author: DexerBRCreated Aug 28, 2024Updated Sep 4, 2026
LabelsType: Feature

Description:

In the context of planning for Kivy 3.0, it would be amazing to implement a cross-platform WebView widget that follows the following workflow:

  1. Render the WebView off-screen.
  2. Capture the page drawing to a pixel buffer.
  3. Upload this pixel buffer to an OpenGL texture, enabling its integration with the Kivy graphical interface.

The proposal includes specific approaches for each supported platform:

Desktop (Windows/Linux/macOS): Off-screen rendering will be achieved using the CEF (Chromium Embedded Framework) https://github.com/chromiumembedded/cef. Pixel buffer output is officially supported by the OnPaint method of the CefRenderHandler class, which simplifies integration.

Android: For Android, the approach involves using the native WebView (https://developer.android.com/reference/android/webkit/WebView), configured for off-screen rendering. The best approach for the workflow above needs further investigation.

iOS: For iOS, it is necessary to determine the best strategy for capturing the content of a WebView and rendering it to an OpenGL texture. Considerations include:

  • What is the most effective approach for iOS? Are there any recommended frameworks or techniques for off-screen rendering with WebView on iOS?
  • Are there frameworks comparable to CEF that can be used on iOS for this purpose?
  • What specific challenges might arise when implementing this functionality on iOS?

Additional Context:

The goal is to ensure that, regardless of the platform, Kivy 3.0 can provide a consistent and integrated user experience when rendering web content into OpenGL textures.

Contributions to discuss and define the best approach for Android and iOS are welcome, aiming to ensure a robust and efficient implementation.


EDIT 1: Here is a proof of concept for the latest version of CEF (using the most recent stable version, Chromium version 128.0.6613.18) running based on the workflow mentioned above, on Windows. However, the behavior should be identical on both macOS and Linux.

https://github.com/user-attachments/assets/aeeed281-e141-4a8f-95be-4066bc4229a5