ultralight-godot SHOWCASEshabbywu/ultralight-godot

API / CLASS REFERENCE

UltralightView

Inherits: TextureRect

Render HTML, CSS and JavaScript in a Godot TextureRect.

Render HTML, CSS and JavaScript in a Godot TextureRect. Initializes automatically after entering the tree with a nonzero size. Use load_url or load_html for runtime navigation, and UltralightAPI to install application bindings before page scripts and restore them after navigation. New evaluations use shared containers and explicit UltralightResult errors. Navigation, rebuild and close invalidate document handles and pending tasks. Logic and rendering run on the Godot frame loop; AppCore is not required.

Properties

Methods

acceleratedbool

Request GPU rendering through Godot RenderingDevice. Configure before initialization. Compatibility, headless and unavailable devices use CPU Surface rendering. Use is_accelerated to check the actual backend. Reinitialization reloads the page.

Default: — · Accessors: set_accelerated() / get_accelerated()

max_render_fpsint

Limit this view's animation and repaint rate. Changes apply immediately and survive init_view. Zero removes the per-view limit; the SDK edition ceiling still applies (60 FPS for the public Free edition). Godot frame limits and VSync are independent.

Default: — · Accessors: set_max_render_fps() / get_max_render_fps()

source_typeint

Initial page source: 0 selects URL, 1 selects inline HTML.

Default: — · Accessors: set_source_type() / get_source_type()

initial_urlString

URL loaded during initial automatic initialization when source_type is 0.

Default: — · Accessors: set_initial_url() / get_initial_url()

initial_htmlString

HTML loaded during initial automatic initialization when source_type is 1.

Default: — · Accessors: set_initial_html() / get_initial_html()

initial_base_urlString

Base URL for relative resources in initial inline HTML.

Default: — · Accessors: set_initial_base_url() / get_initial_base_url()

document_readybool

Whether the current main document has reached DOM readiness. Read-only.

Default: — · Accessors: is_document_ready() · Read-only

navigation_idint

Main-document generation identifier. Read-only.

Default: — · Accessors: get_navigation_id() · Read-only

current_urlString

Current main-document URL, separate from initial source configuration. Read-only.

Default: — · Accessors: get_current_url() · Read-only

htmlString

Legacy inline source setter. Prefer initial_html and source_type or runtime load_html.

Default: — · Accessors: set_html_content() / get_html_content()

htmlUrlString

Legacy URL source setter. Prefer initial_url or runtime load_url.

Default: — · Accessors: set_html_url() / get_html_url()

transparentbool

Enable a transparent page background. Configure before initialization. Changing it on an existing view requires reinitialization.

Default: — · Accessors: set_transparent() / get_transparent()

lazybool

Defer automatic initialization. Explicit load requests initialize after layout even when lazy is enabled.

Default: — · Accessors: set_lazy() / get_lazy()

set_accelerated

set_accelerated(enabled: bool) → void

Set accelerated.

get_accelerated

get_accelerated() → bool const

Return accelerated.

is_accelerated

is_accelerated() → bool const

Return whether this view actually uses GPU RenderingDevice. A request through accelerated can fall back to CPU if the device is unavailable or initialization fails.

get_render_statistics

get_render_statistics() → Dictionary const

Return rendering statistics. These fields are always present:

  • accelerated: actual rendering backend.
  • sdk_edition, sdk_max_fps: SDK edition and its frame-rate ceiling; zero means no edition ceiling.
  • max_render_fps: requested per-view frame-rate limit.
  • ultralight_render_us: Ultralight rendering time in microseconds, shared across all views.
  • cpu_page_upload_bytes, cpu_mipmap_count, cpu_upload_us: CPU Surface upload counters for this view. These survive reinitialization.

Only an active accelerated view adds GPU fields: gpu_available, bitmap_upload_bytes, geometry_upload_bytes, state_upload_bytes, draws, batches, feedback_copies, render_passes, rd_record_us, gpu_us and gpu_draws_by_shader. GPU counters cover all views. Zero GPU timing can mean timestamps are unavailable. GPU mode can still upload SDK resource bitmaps, including Canvas content.

CPU, uninitialized and fallback views omit GPU fields. Rendering preparation timings exclude JavaScript execution outside the render call and do not represent total application frame time.

set_max_render_fps

set_max_render_fps(fps: int) → void

Set max_render_fps.

get_max_render_fps

get_max_render_fps() → int const

Return max_render_fps.

get_bridge_statistics

get_bridge_statistics() → Dictionary const

Return counts of active bindings, host container proxies, host object proxies and retained JavaScript handles for diagnostics.

unbind

unbind(name: String) → void

Revoke the current temporary export with this name, including nested proxies.

load_url

load_url(url: String, timeout: float = 30.0) → UltralightTask

Navigate to url and return a task that completes at main-document DOM readiness. timeout is in seconds, finite and greater than zero. Before layout, the request waits for a usable size.

load_html

load_html(html: String, base_url: String = "", timeout: float = 30.0) → UltralightTask

Load inline HTML with base_url for relative resources. Return a task for main-document DOM readiness; timeout is in seconds.

reload

reload(timeout: float = 30.0) → UltralightTask

Reload the current page and return its DOM readiness task. An inline page retains its HTML and base URL.

wait_ready

wait_ready(timeout: float = 30.0) → UltralightTask

Observe the current main document. May complete immediately when already ready. Navigation invalidates an unfinished wait.

wait_for_selector

wait_for_selector(selector: String, timeout: float = 30.0) → UltralightTask

Wait until a CSS selector matches an element in the current main document. Invalid selectors fail. This checks existence, not visibility.

evaluate

evaluate(source: String) → UltralightResult

Evaluate source and return an explicit result. Arrays and objects are live shared handles; null is Nil and undefined is UltralightUndefined.

evaluate_copy

evaluate_copy(source: String) → UltralightResult

Evaluate source and recursively copy own enumerable data into independent Godot containers. Cycles, unsupported values and depth over 64 fail.

evaluate_handle

evaluate_handle(source: String) → UltralightResult

Evaluate source and retain its raw JavaScript value, including primitives, in an UltralightJSValue handle.

evaluate_async

evaluate_async(source: String, timeout: float = 30.0) → UltralightTask

Evaluate source and observe a returned Promise, or complete with an ordinary value. Timeout is in seconds. Navigation cancels delivery to the old document.

is_closed

is_closed() → bool const

Return whether close has permanently disabled this View.

close

close() → void

Permanently close this View, detach API registries, invalidate document handles and finish pending tasks.

is_initialized

is_initialized() → bool const

Return whether the native SDK View exists.

is_loading

is_loading() → bool const

Return whether the main document is loading.

is_document_ready

is_document_ready() → bool const

Return document_ready.

get_navigation_id

get_navigation_id() → int const

Return navigation_id.

get_current_url

get_current_url() → String const

Return current_url.

get_last_load_error

get_last_load_error() → UltralightError const

Return the latest structured main-document load error, or null when no error is recorded.

input_text

input_text(text: String) → void

Send committed text to the focused page. This does not provide IME preedit or candidate-window positioning.

scroll_pixels

scroll_pixels(delta: Vector2) → void

Send a pixel scroll delta to the page.

set_source_type

set_source_type(value: int) → void

Set source_type.

get_source_type

get_source_type() → int const

Return source_type.

set_initial_url

set_initial_url(value: String) → void

Set initial_url.

get_initial_url

get_initial_url() → String const

Return initial_url.

set_initial_html

set_initial_html(value: String) → void

Set initial_html.

get_initial_html

get_initial_html() → String const

Return initial_html.

set_initial_base_url

set_initial_base_url(value: String) → void

Set initial_base_url.

get_initial_base_url

get_initial_base_url() → String const

Return initial_base_url.

set_html_content

set_html_content(html: String) → void

Set html.

get_html_content

get_html_content() → String

Return html.

set_html_url

set_html_url(htmlUrl: String) → void

Set htmlUrl.

get_html_url

get_html_url() → String

Return htmlUrl.

set_transparent

set_transparent(is_transparent: bool) → void

Set transparent.

get_transparent

get_transparent() → bool

Return transparent.

set_lazy

set_lazy(is_lazy: bool) → void

Set lazy.

get_lazy

get_lazy() → bool

Return lazy.

rebuild

rebuild() → void

Recreate the native View to apply backend configuration. Invalidates old document state and tasks; attached API registries are restored for the new document.

init_view

init_view() → void

Compatibility alias for rebuilding. Automatic initialization and explicit load methods handle ordinary layout and loading.

bind_func

bind_func(funcName: String, callback: Callable) → void

Compatibility function export. New code should use bind_function or UltralightAPI.register_function.

bind_object

bind_object(name: String, object: Object, options: UltralightBindingOptions = null) → UltralightBinding

Export a temporary Godot Object with optional UltralightBindingOptions. Return its revocable binding. Use UltralightAPI.register_object for persistent exports or root Array and Dictionary containers.

bind_function

bind_function(name: String, function: Callable, options: UltralightBindingOptions = null) → UltralightBinding

Export a temporary global function and return its revocable UltralightBinding. For navigation persistence use UltralightAPI.

bind_object_legacy

bind_object_legacy(propertyName: String, instance: Object, query_members: bool = false) → void

Compatibility entry for the old query_members boolean. New code should use UltralightAPI and UltralightBindingOptions.

execute_script

execute_script(script: String) → Variant

Compatibility evaluation using copied values and Nil/logged errors. Prefer evaluate for explicit errors and shared values.

fire_key_event

fire_key_event(key_event: InputEventKey) → void

Forward a keyboard event to an initialized page. Normal Control input forwards key events while the web view has focus.

fire_mouse_event

fire_mouse_event(position: Vector2, button_index: MouseButton, is_pressed: bool) → void

Forward a mouse event to an initialized page. position uses coordinates local to the web view, in pixels. Pass MOUSE_BUTTON_NONE for motion, a mouse button with is_pressed for press/release, or a wheel button for scrolling. The Control normally forwards its own GUI input automatically.

Signals

load_started

load_started(event: UltralightFrameEvent)

Main-document loading has started.

window_ready

window_ready(event: UltralightFrameEvent)

Main-document global is available. API registries are installed, and page scripts have not yet executed.

dom_ready

dom_ready(event: UltralightFrameEvent)

Main-document DOM is ready. State is updated before dispatch. Does not imply application async work is finished.

frame_dom_ready

frame_dom_ready(event: UltralightFrameEvent)

Any frame DOM is ready, including the main frame. Inspect event.is_main_frame and event.frame_id.

load_finished

load_finished(event: UltralightFrameEvent)

Main-document loading finished. Does not guarantee permanent network inactivity.

load_failed

load_failed(failure: Dictionary)

Main-document failure. failure contains event, error, domain and code.

console_message

console_message(message: Dictionary)

Page console entry. Includes level, message, source_url, line, column and navigation_id when available.

on_window_object_ready

on_window_object_ready()

Compatibility signal. Prefer window_ready(event) and persistent UltralightAPI registrations.

on_dom_ready

on_dom_ready()

Compatibility main-document DOM signal. Prefer dom_ready(event); iframe notifications use frame_dom_ready(event).

Internal lifecycle callbacks

on_update_frame

on_update_frame() → void

Internal lifecycle callback. Publishes the rendered texture after Godot drawing. It is connected automatically; applications should not invoke it.

on_resized

on_resized() → void

Internal lifecycle callback. Resizes an initialized page to match the Control. It is connected automatically; applications should not invoke it.

View class documentation source ↗

Godot screenshot · Press Esc to close Open original image ↗