Extension causes high cpu load when running preview with code that contains multiline comments
Closed this issue · 4 comments
Hi,
I encountered an issue when running the Shader Toy: Show GLSL Preview
command with code that contains c-style multiline comments. Upon running the command, the editor becomes unresponsive to keyboard input in combination with the plugin vscodevim.
Here are the generated descriptions of the issue:
- Issue Type:
Performance
- Extension Name:
shader-toy
- Extension Version:
0.10.8
- OS Version:
Linux x64 5.6.14-arch1-1
- VSCode version:
1.45.1
stevensona.shader-toy-unresponsive.cpuprofile.txt
/******************************************************************************
* Multiline Comment
******************************************************************************/
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
// Normalized pixel coordinates (from 0 to 1)
vec2 uv = fragCoord/iResolution.xy;
// Time varying pixel color
vec3 col = 0.5 + 0.5*cos(iTime+uv.xyx+vec3(0,2,4));
// Output to screen
fragColor = vec4(col,1.0);
}
Huh, I thought I got all comment parsing problems last time. Will check this out later today.
Thanks for bringing it to our attention :)
As you suggested, this was a bug in parsing multi-line comments. You freaked out our naive strategy by putting a lot of asterisks in your comment *shakes fist*
The new strategy should cover all cases (as per the language definition):
When encountering the token sequence /*
ignore everything until finding the token /
and stop if the previous token is a *
, if not continue ignoring.
So this doesn't handle nested multi-line comments, but neither does the GLSL spec, so there's no harm done by us at lest.
Edit: This fix will probably be published in the coming days.
Thank you very much for taking care of it so quickly! I will look for the update and rethink my code comment behavior :)
Just tested it with the updated plugin and it worked fine now. Thank you!