Three.min.js:2 THREE.WebGLProgram: shader error: 0 35715 false gl.getProgramInfoLog THREE.WebGLShader: gl.getShaderInfoLog() vertex

Below is the code that is running to create canvas and use it as image to create a PDF. the scene is created and then its been taken as snapshot. But when render is called. the below error appears. Kindly help me to understand why this error may appear.

var old_pogjson = JSON.parse(JSON.stringify(POGJSON));
var new_pogjson = JSON.parse(JSON.stringify([POGJSON[pPogIndex]]));
var old_scene = scene_objects[0].scene;
var old_renderer = scene_objects[0].renderer;
var old_world = world;
var old_live_image = g_show_live_image;
var old_item_desc = g_show_item_desc;

var mod_array = [];
var z = 0;
var next_mod = 0;
var mod_width = 0;
var base_width = 0;
var img_arr = [];
var total_width = 0;
var total_height = 0;
var total_depth = 0;
var bay = "";
console.log("old_pogjson[0].ModuleInfo", old_pogjson[0].ModuleInfo);
var total_mod_cnt = 0;
var count = 0;
if (pshowLiveImg == "Y") {
    g_show_live_image = "Y";
} else if (pDesc == "Y" || pDesc == "IDUVCDP" || pDesc == "IFEC") {
    if (pDesc == "IDUVCDP" || pDesc == "IFEC") {
        g_temp_desc = pDesc;
    } else {
        g_temp_desc = "N";
    }
    g_show_live_image = "N";
    g_show_item_desc = "Y";
}
if (ppdfnotchlabel == "Y") {
    g_show_notch_label = "Y";
} else {
    g_show_notch_label = "N";
}
if (pPdfFixelLabel == "Y") {
    g_show_fixel_label = "Y";
} else {
    g_show_fixel_label = "N";
}
if (pPdfItemLabel == "Y") {
    g_show_item_label = "Y";
} else {
    g_show_item_label = "N";
}
for (const modules of old_pogjson[0].ModuleInfo) {
    if (typeof modules.ParentModule == "undefined" || modules.ParentModule == null) {
        total_mod_cnt++;
        total_width = total_width + modules.W;
        total_height = Math.max(total_height, modules.H);
        total_depth = Math.max(total_depth, modules.D);
    }
}
for (const modules of old_pogjson[0].ModuleInfo) {
    if (typeof modules.ParentModule == "undefined" || modules.ParentModule == null) {
        count++;
        mod_array.push(modules);
        next_mod++;
        base_width = base_width + modules.W;

        console.log("next_mod", next_mod, pBayCount);
        if (next_mod == pBayCount || total_mod_cnt == count) {
            new_pogjson[0].ModuleInfo = mod_array;
            new_pogjson[0].BaseW = base_width;
            new_pogjson[0].W = base_width;
            new_pogjson[0].BaseX = base_width / 2;
            base_width = 0;
            console.log("i", i, pBayCount);
            if (z + 1 == pBayCount) {
                new_pogjson[0].TotalModWidth = 0;
                console.log("insde");
            } else {
                new_pogjson[0].TotalModWidth = mod_width;
            }
            if (typeof g_renderer_pdf !== "undefined" && g_renderer_pdf !== null && g_renderer_pdf !== "") {
                g_renderer_pdf.forceContextLoss();
                g_renderer_pdf.context = null;
                g_renderer_pdf.domElement = null;
                g_renderer_pdf = null;
            }
            if (typeof renderer !== "undefined" && renderer !== null && renderer !== "") {
                renderer.forceContextLoss();
                renderer.context = null;
                renderer.domElement = null;
                renderer = null;
            }

            init_pdf(window.innerWidth, window.innerHeight, 10, "Y", "N");
            //document.body.appendChild(new_canvas);
            console.log("mod_array", mod_array, new_pogjson, mod_width, new_pogjson[0].TotalModWidth);
            //scene_objects[0].scene = g_scene_pdf;
            //scene_objects[0].renderer = g_renderer_pdf;
            //canvas_objects[0] = new_canvas;
            scene = g_scene_pdf;
            camera = g_camera_pdf;
            world = g_world_pdf;
            renderer = g_renderer_pdf;
            await create_module_from_json_lib(new_pogjson, "T", "F", "N", "N", "Y", "Y", pVdate, pPogDftColor, pModDftColor, null, false, "Y", null, pDftSpreadProduct, pDftHorizSpac, pDftVertSpac, pBskWallThick, pChestWallThick, pPegItemAutoPlace, pDftWrapText, pTextDftSize, pTextDftColor, pShelfDftColor, pDivColor, pSlotDivider, pSlotOrient, pDivFixed, pItemDftColor, pDelistDftColor, g_peg_holes_active, pShelfDftColor, 1, pMerchStyle, pLoadImgFrom, pBuid, pDelistDftColor, pItemNumLblColor, pDispItemInfo, pItemNumLblColor, pItemNumLblPos, pNotchHead, "N", pDftBskFill, pDftBaskSprd, camera, 0, 0);
            bay = "";

            for (const mod_dtl of mod_array) {
                mod_width = mod_width + mod_dtl.W;
                if (bay == "") {
                    bay = (mod_dtl.W * 100).toFixed(2);
                } else {
                    bay = bay + "|" + (mod_dtl.W * 100).toFixed(2);
                }
            }
            for (const modules of POGJSON[0].ModuleInfo) {
                if (typeof modules.ParentModule == "undefined" || modules.ParentModule == null) {
                    for (const shelfs of modules.ShelfInfo) {
                        if (shelfs.ObjType == "TEXTBOX") {
                            var selectedObject = world.getObjectById(shelfs.SObjID);
                            selectedObject.material.transparent = false;
                        }
                    }
                }
            }
            if (g_renderer_pdf !== null) { **// error comes at this line**
                g_renderer_pdf.render(g_scene_pdf, g_camera_pdf);
            }
            animate_test1();
            mod_array = [];
            next_mod = 0;
            var retval = await timeout(120);
            var details = get_min_max_xy(0);
            var details_arr = details.split("###");
            set_camera_z(camera, parseFloat(details_arr[2]), parseFloat(details_arr[3]), parseFloat(details_arr[0]), parseFloat(details_arr[1]), 1, parseFloat(details_arr[4]), parseFloat(details_arr[5]), true, 0);
            console.log("inside", new_pogjson, mod_array);
            var dataURL = new_canvas.toDataURL("image/jpeg", penhance);
            console.log(" after  base64 ", getDateTime());
            var img_details = {};
            img_details["Module"] = "COMBINE";
            img_details["Bay"] = bay;
            bay = "";
            //img_details['ImageBase'] = base64;
            img_details["ImgData"] = dataURL.match(/,(.*)$/)[1];
            img_arr.push(img_details);
        }
    }
    console.log("modules", modules, z);
    console.log("old_pogjson[0].ModuleInfo", old_pogjson[0].ModuleInfo);
    z++;
}
if (typeof g_renderer_pdf !== "undefined" && g_renderer_pdf !== null && g_renderer_pdf !== "") {
    g_renderer_pdf.forceContextLoss();
    g_renderer_pdf.context = null;
    g_renderer_pdf.domElement = null;
    g_renderer_pdf = null;
}
g_temp_desc = "N";
g_show_live_image = old_live_image;
g_show_item_desc = old_item_desc;
POGJSON = old_pogjson;
scene_objects[0].scene = old_scene;
scene = old_scene;
scene_objects[0].renderer = old_renderer;
renderer = old_renderer;
world = old_world;
render(0);
return img_arr;

Below is the error in console.


You’ll probably need to post this in a form that we can debug… preferably a glitch or a codepen.

Here’s a glitch template you can use… put your code inside script.js (near the bottom there’s a comment where to add stuff)

Hey Thanks for your advise. i may add and post it here soon for the help.

1 Like

I found out the problem. We are creating 2 different canvas and renderer which will show the scene on the browser and another canvas will create scene for taking screen shot for PDF generation. I was assigning one renderer to another, when i commented this the error is gone now. i feel both renderer where active and assigning one to another is causing some corrupt in renderer.

Also using texture as variable name could also cause this. i just read in other blog but did not see any difference for my case.

Anyways thanks for your reply and advise.

1 Like

You’re welcome! Good luck!