High-performance, hardware-accelerated GPU-to-GPU Android WebView rendering layer for the Kivy framework.
Project description
nfswebview
nfswebview is a high-performance, hardware-accelerated, GPU-to-GPU Android WebView rendering layer specifically engineered for the Kivy framework. By bypassing standard off-screen bitmap blitting, it directly hooks the Android hardware compositor into Kivy’s OpenGL ES context via a specialized GL_TEXTURE_EXTERNAL_OES pipeline.
This library delivers native 60 FPS scrolling, full support for hardware-accelerated WebRTC (video/audio streams), HTML5 Geolocation, advanced input handling (touch event mapping), and complete compatibility up to Android 16 (API 36).
Architecture & Pipeline Overview
Standard off-screen rendering techniques capture web contents via pixel arrays, causing massive CPU bottlenecks. nfswebview eliminates this overhead through direct GPU memory mapping:
- OpenGL OES Binding: The Python wrapper initializes an external OpenGL texture pointer (
GL_TEXTURE_EXTERNAL_OES) via Kivy's graphics engine. - Surface Association: This texture ID is passed through Pyjnius to instantiate a native Android
SurfaceTextureand underlying hardwareSurface. - Offscreen Composite Routing: The native Java controller (
NfsWebview) forces the WebView's hardware canvas to draw explicitly to our targetSurface. - Custom Shading: A specialized GLSL fragment shader samples the external OES surface texture directly into Kivy’s drawing canvas canvas matrix.
- Bidirectional Input Bridges: Touch vectors and keycodes are captured inside Kivy, translated to native Android scales, and injected directly into the WebView's event dispatch loop.
Quick Start & Usage
1. Initializing the UI Widget
Import the NfsWebviewWidget directly into your layout hierarchy just like any standard Kivy component.
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from nfswebview import NfsWebviewWidget
class WebBrowserApp(App):
def build(self):
layout = BoxLayout(orientation='vertical')
self.webview = NfsWebviewWidget(url="[https://github.com](https://github.com)")
layout.add_widget(self.webview)
return layout
if __name__ == '__main__':
WebBrowserApp().run()
2. Executing JavaScript Code
You can inject synchronous or asynchronous JavaScript executions straight from your Python logic into the active web space:
# Execute directly from Kivy thread (handled safely on the UI Thread under-the-hood)
self.webview.eval_js("document.body.style.backgroundColor = 'black';")
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nfswebview-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nfswebview-1.0.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27bce4930b3f231da3a532ef7b1ca9b70854391bc8cd30f8660d02c95f52b3f1
|
|
| MD5 |
dc6ed1d97621ad34e2e5d450ea4e62cb
|
|
| BLAKE2b-256 |
dfb6c3372d300577ef3850536510a57115e62eb82f78d3fcd8c5fc102f39a6ed
|