Thanks to visit codestin.com
Credit goes to github.com

Skip to content

WebGL2RenderingContext has two reflectors #45066

@jdm

Description

@jdm

pub(crate) struct WebGL2RenderingContext {
reflector_: Reflector,
base: Dom<WebGLRenderingContext>,

This is wrong. The WebGLRenderingContext is supposed to be the first field of the struct, not stored separately in a Dom wrapper.

However, this is complicated by this code:

let samplers = (0..base.limits().max_combined_texture_image_units)
.map(|_| Default::default())
.collect::<Vec<_>>()
.into();
let indexed_uniform_buffer_bindings = (0..base.limits().max_uniform_buffer_bindings)
.map(|_| IndexedBinding::new())
.collect::<Vec<_>>()
.into();
let indexed_transform_feedback_buffer_bindings =
(0..base.limits().max_transform_feedback_separate_attribs)
.map(|_| IndexedBinding::new())
.collect::<Vec<_>>()
.into();

We need the limits obtained from creating the context in order to initialize the new DOM context object. I think the way forward here is to extract

if pref!(webgl_testing_context_creation_error) {
return Err("WebGL context creation error forced by pref `webgl.testing.context_creation_error`".into());
}
let webgl_chan = match window.webgl_chan() {
Some(chan) => chan,
None => return Err("WebGL initialization failed early on".into()),
};
let (sender, receiver) = webgl_channel().unwrap();
webgl_chan
.send(WebGLMsg::CreateContext(
window.webview_id().into(),
webgl_version,
size,
attrs,
sender,
))
.unwrap();
let result = receiver.recv().unwrap();
into a separate static method that can be called from both WebGLRenderingContext::new and WebGL2RenderingContext::new, and WebGLRenderingContext::new_inherited can just take the values that it needs as arguments.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-content/webgl3d canvas APIE-less-complexStraightforward. Recommended for a new contributor.I-wrongAn incorrect behaviour is observed.

    Type

    No type
    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