When my ThreeJS custom shaders contains errors, I get the very cryptic INVALID_OPERATION message in the JS console during the rendering stage:
WebGL: INVALID_OPERATION: useProgram: program not valid
Is there a way to get a more useful log, such as the one returned by getShaderInfoLog()?
(To test this quickly, one can add errors in the shaders of this app.)
For performance reasons, three.js R104 does no longer perform error checking and reporting when shader programs are being compiled. However, multiple users complained about this change so it was recently reverted. With the next release R105, things will be as before (see migration guide).
However, you can manually turn on the previous behavior in R104 by setting renderer.debug.checkShaderErrors to true.
Related
I ran into a debugging issue in a prod environment with Unity Unity 2022.1.24f1 and WebGL. When an exception occurs, I get an unreadable stacktrace. Something like this:
Invoking error handler due to
RuntimeError: unreachable
at wasm://wasm/0785b666:wasm-function[985]:0x98818
at wasm://wasm/0785b666:wasm-function[544]:0x89330
at wasm://wasm/0785b666:wasm-function[8670]:0x24dccf
at wasm://wasm/0785b666:wasm-function[1922]:0xbf4e5
at wasm://wasm/0785b666:wasm-function[28368]:0x812a8b
at wasm://wasm/0785b666:wasm-function[86902]:0x14c5d3c
at wasm://wasm/0785b666:wasm-function[557]:0x898ed
at wasm://wasm/0785b666:wasm-function[77488]:0x1326327
at wasm://wasm/0785b666:wasm-function[5230]:0x171c41
at wasm://wasm/0785b666:wasm-function[10658]:0x2feb0d
at wasm://wasm/0785b666:wasm-function[104320]:0x178c493
at invoke_iiii (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:408461)
at wasm://wasm/0785b666:wasm-function[2104]:0xc4fc3
at wasm://wasm/0785b666:wasm-function[24046]:0x7aace3
at wasm://wasm/0785b666:wasm-function[990]:0x989d5
at wasm://wasm/0785b666:wasm-function[21506]:0x561c30
at wasm://wasm/0785b666:wasm-function[51389]:0xd496a6
at wasm://wasm/0785b666:wasm-function[109425]:0x18f3801
at wasm://wasm/0785b666:wasm-function[108044]:0x1853d4c
at wasm://wasm/0785b666:wasm-function[23913]:0x79ec70
at wasm://wasm/0785b666:wasm-function[23913]:0x79ece1
at wasm://wasm/0785b666:wasm-function[21361]:0x554206
at wasm://wasm/0785b666:wasm-function[104316]:0x178c45d
at browserIterationFunc (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:229388)
at callUserCallback (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:182585)
at Object.runIter (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:183845)
at Browser_mainLoop_runner (blob:http://localhost:8080/eef1af57-52ea-407d-b414-b8a770143494:3:182120)
I can't enable debug symbols mode for prod environment, is there any algorithm to translate this stack trace to real method names?
I found out, that Library\Bee\artifacts\WebGL\il2cppOutput\cpp\Symbols\MethodMap.tsv file has all method names from my app, but I didn't found any relations between those method names/their serial number and numbers in stacktrace.
MethodMap.tsv contains the relationship between c# and c++ functions. This is the first stage of compiling to WASM. The second step creates in build directory a file .symbols.json (for Unity 2021 and newer, in older versions it has a different name). It contains the relationship between c++ and wasm functions. But to get this file, you need to set "Debug symbols" in "Publishing settings" to "External" value.
I'm having an issue with "Source Not Available" when trying to run the HLSL debugger. Is there a way of attaching a hlsl source? If not is there a special location where the source file needs to be in?
The big problem is that I'm not getting anything drawn and as far as I can see is that after the vertex shader everything is discarded.
Goal: I'm trying to develop my first simple Oculus rift application using visual studio.
Background: Computer Engineer/programmer of arbitrary languages-rusty at C++/very rusty at visual studio/inexperienced with 3D balls to the wall programming.
DirectX Progress: I found this excelent tutorial (http://3dgep.com/introduction-to-directx-11/) and I rebuilt it walking thru the code; this taught me a lot. My code never actually would run though, likely an issue with linkers or precompiled headers, so I reverted back to the original Demo File.
Oculus Progress: I've learned a lot about using the LibOVR, successfully compiled my first program which was to gather sensor data. Never ran it though.
Visual Studio: I currently have one solution setup, with two projects (DirectXTemplate and LibOVR). I'm thinking I should merge the two projects and turn the DirectXTemplate into a library so I can access all the functions defined in these files (though I will likely need to modify them as development progresses). How do I go about doing this? Is this the right thing to do?
I also have some general questions:
List item
Projects/Solutions: what is the difference and how should I lay things out to achieve my goal?
List item
My winAPI main function is in my own cpp file, it calls functions from directXtempalte... most of these are working except the LoadContent function fails about half way thru, I think due to the shaders. I'm really confused about the shaders in the tutorial, particularly walking about at compile time vs. at run time shaders and suspect its an issue with the Linker, precompiled headers, include directories or something like that. There are so many views of the properties tab in VS its causing more confusion and errors. So my real question here is how do I control this better? I mean, the properties window changes depending on what project/solution/file I select and it also changes based on the mode selected in the properties window... getting the properties window right for all these objects has proven to be a highly error prone process requiring iterative trial and error... this really really sucks and wastes tons of time... How can it be avoided?
List item
How do I turn the directX template in to a library like the LIBOVR and should I? Keep in mind the directX template/library will be updated massively as the project progresses but LIBOVER will not be. When all things are done, I'll be using the LIBOVR functions for to deal with the oculus (this is static but is updated by the Vendor) and DirectXTemplate/Library functions to deal with direct X (this will be custom build, using the template as the starting point.
I'm building off a project in three.js and one of the ideas I'm fiddling around with would allow users to write their own shader code. Code from the user would dynamically load to the gpu, much like in this example. In such a setup, the user would benefit greatly from having some way to display compile time errors generated by his code. I've looked into the code from the above example, but this instance works directly with WebGl.
Are there any alternatives I might consider that leverage the three.js library to detect compile time shader errors?
I'm just guessing but it looks like what you'd want to do is use WebGL to compile and link the shaders. If there are errors display them. If compiling and linking was successful then make a three.js ShaderMaterial and pass in the shader source that just worked.
If you view-source on glsl.heroku.com/e you can see in the createShader code it checks for errors and attempts to highlight specific lines in the source.
I have recently converted my project to use ARC (Automatic Reference Counting).
It doesn't really do a very good job of knowing when to actually release an object, and often because I have lots of allocations being performed, my application has excessively high memory usage because the existing objects aren't being deallocated when they're closed from view.
All I need to be able to do is disable ARC for that file, and everything should be OK. I did that, added the release statement, and it worked perfectly. Except of an error.
Whenever the project isn't being built (ie. the error disappears and the build succeeds while building it) it shows an error stating that ARC prohibits the sending of the release message to an object, even though I explicitly added an exception for that file in the Project Settings.
All I really need to do is silence the error, as there is no error (as it builds successfully).
Any help appreciated.
Well, after several builds and cleans, the error has miraculously disappeared.
These problems have been frequent in Xcode 4, I got an unused variable warning from something that was clearly being used.