So I've run into this issue a few times using Processing (p5.js mode), where seemingly out of the blue it doesn't want to compile.
The error reads: "SyntaxError: Expected ; but found [name of my first variable]"
I can literally copy and paste the code into a new processing sketch and it runs. It's just annoying that I have to do that.
The last thing I did this time before it stopped working was rename the sketch. I can't remember if that's what happened with the other times I've had this issue, but I'm betting I would have been aware of that if so.
Any guidance on how to avoid this problem & correct it when it happens would be greatly appreciated.
Thanks
edit I should have mentioned that if I just double click the HTML file, the sketch runs fine. It's only when I try to run it in processing that I get the error.
edit number two on a different laptop with a new download of processing, the same error occurs in the IDE, while the sketch runs if I just double click the HTML file. I'm left to believe the issue starts and stops with the processing IDE.
This is a known bug (or, arguably, a feature) in the p5js mode of the Processing IDE. This mode apparently has an internal JavaScript parser which is stuck in ES5. For example, the following code works fine in any major browser:
let x = 0;
let y = 0;
function setup() {
createCanvas(200,200);
background(0);
fill(255);
x = 0;
y = width/2;
}
function draw() {
rect(x,y,10,10);
x = (x+1)%width;
y = (y+random(5))%height;
}
but you will run into problems when you try to work with it in the p5.js mode of the PDE. The problem disappears when let is replaced by var. Similar issues arise if you try to use code like myArray.map(x => x*x)
The p5.js mode seems like a small project with very little new code within the last year, so I wouldn't hold my breath on a fix. The github description of the project in one place says:
As with the rest of Processing, if you outgrow this setup, you should
use another IDE or development solution (like a full-featured
programmer's text editor and similar tools). We have no interest in
creating a JavaScript IDE. Also like the rest of Processing, we want
people to outgrow this setup.
Sounds like you have outgrown the set up. I recommend using something like Brackets instead.
Related
https://codepen.io/chrisjdesigner/pen/ExNPqBx
// Old Film Look
filmPass = new THREE.FilmPass();
composer.addPass(filmPass);
In this example you can see it and it's something I've been having in my own tests as well. I'm not sure if it's only tabbing out or if by leaving the computer idle it eventually turns like that.
The way to replicate it is to open the demo, leave the tab for a while and after 15 minutes or so, when you return to the tab, the noise will look displaced and forming patterns
. Chrome latest version.
My assumption is that the requestanimationframe is causing this issue, but I wouldn't know what to tweak to fix it.
Anyone got a pointer?
It appears adding a deltatime to the render alleviates the issue greatly.
I’m working on a complex project in threejs.
Trying to cut the corner:
I have to load an obj, create some pivot point to use as parent of the mesh inside this obj, let the user move and rotate the pivots.
It takes somewhere about 10 to 15 seconds to load due to its complexity.
My problem is that it is working flawlessly if I load the page and don’t change the focus, but if I change the browser tab or collapse the browser window I got a very specific problem:
geometry.computeBoundingBox() gives different results.
Is there someone who can help me figure out what’s happening?
To help you better understand the situation: at loading time I have to rotate the obj to -90° on the X axis (inverting Y and Z as a consequence); I think it’s relevant because the boundingBox calculation somehow inverts Y and Z and changes its min and max also, but as I said only if I switch tab or collapse the browser.
p.s. No matter the OS nor the browser. It’s a super consistent bug
Ok, I somehow solved the issue, but take it with a grain of salt:
the problem can be tracked back to the execution stack of javascript:
the first function computes the bounding box, the second uses this computation, but if the first function is somehow slower to execute, the second could not have what it needs.
What I did is to force javascript to execute functions in a given order and only when the previous is finished.
The problem occurred only when changing the tab because browsers optimize resources of non visible tabs, but the code I wrote was anyway too much entropic to work properly.
I hope what I found will be understandable and useful to someone else in future.
I do not understand why OpenCV doesn't work when we do not need to create OpenCV window using cvNamedWindow.
Actually, I do not want to use OpenCV GUI window, I want to use third party GUI in order to display grabbed frame, So for this, i do not need to create OpenCV window. But When I do not create OpenCV window, my application gets stuck, nothing works, and when I do create OpenCV window using cvNamedWindow, everything works fine.
Any suggestion, whats the reason? how can I grab OpenCV frame without creating its GUI window?
I am using OpenCV 2.4.3 (cvQueryFrame), VS2010 c++, WindowsXP
Thanks.
you probably need to skip the waitKey() call, too ;)
(also, do yourself a favour, and skip the c-api. it's a real PITA and will go away soon)
That's because you are grabbing images at a faster rate than what the camera can ouput. You need to add a little delay to your while cycle. If your camera does 25FPS, you should add ~1/25 of a second or so.
Solved: The problem was this, actually, I was creating a third party GUI window inside of the pthread which was causing its infinite updating. When I created window outside of the pthread, it works fine.
procedure is this:
void Init()
{
createGUIwin(w, h);
init_pthread();
}
void init_pthread(void*)
{
//createGUIwin(w, h); // before I was creating GUIwin here
while(ON)
{
frame = getOCVframe();
UpdateGUIwin(frame);
key = cvWaitKey(10);
}
}
Thanks everyone. I appreciate your answers.
I'm trying to do some animations using Java3D on a Mac.
If I use universe = new SimpleUniverse(); to create a universe, everything is fast. The problem is that there's a bit of tearing sometimes because I'm altering object properties while in the middle of rendering. What I would like to do is stop the rendering while I'm updating properties.
My first step was to try creating my own Canvas3D, and that's where things went wrong. Rather than just creating a SimpleUniverse, I do this sort of thing:
GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
canvas = new Canvas3D(config);
universe = SimpleUniverse(canvas);
When I do this, the first problem is that the window doesn't automatically appear. So based on the example at java2s, I embedded the Canvas3D in an applet. Then I get a window, but performance is TERRIBLE. The rendering is MUCH slower.
It's almost as though the rendering is no longer being done by the graphics engine but instead in software.
Can anyone give me some tips as to what I'm doing wrong here?
Thanks!
You should try compiling your BranchGroups before they become live. This helps preprocess the objects before they get displayed in the universe. It might also be something else that java is getting hung up on, if you put the whole source in the question, then i could tell you more. It might also just be your computer, Java3D takes a big hunk of Memory and is pretty CPU intensive, your computer specs would also be relevant in answering this question
Hope that helped you out a little bit, if you add more to your question i would be happy to help you more
I’m building a mobile web application, and even though I’m still in a prototyping kind of the process, I’m having a hard time fixing certain performance problems.
The application itself (works all smooth in desktop browsers, but significantly sluggish in Mobile Safari): Hancards webapp prototype. You may login as mifeng:wangwang or create a new user.
The overall clumsy performance could be tolerable though, except for one thing: the browser simply crashes (!) when you open a set page, tap ‘view’ (enlarge all cards) and then try to go back to the previous page.
The code that gets executed when ‘view’ is tapped is this (very sluggish by itself as well; any way to improve it?):
if ($(this).hasClass('big')) {
$('.card').unwrap().removeClass('big flippable').addClass('small');
$(this).removeClass('big');
}
else {
$('.card').wrap('<div class="bigCardWrap" />').removeClass('small').addClass('big flippable');
$(this).addClass('big');
}
And another thing, a pretty weird bug. Very often the ‘word of the day‘ block won’t display the text node for the last element (<div class="meaning">), even though it’s in the code. The text will not show unless you ‘shake’ the DOM anyhow (unticking and ticking back one of the associated CSS properties can also achieve that). This happens in both desktop and mobile Safari browsers.
The code that writes it in there is this:
// While we are here, also display the Word of the day
$.post('ajax.php', {action: 'stuff:showWotd'}, function(data) {
// Decode the received data
var msg = decodeResponse(data);
// Insert the values
$('.wotd .hanzi').text(msg.content[0]['hanzi']);
$('.wotd .pinyin').text(msg.content[0]['pinyin']);
$('.wotd .meaning').text(msg.content[0]['meaning']);
});
I don’t expect you to advice me on how to fix the performance of the whole application (I will probably have to revise the overall scope of the project instead of trying to find workarounds), but I at least would like to see how to solve these two problems. Thank you!
The only performance issue I see in the script is the wrap/unwrap calls - adding and removing elements from the DOM tends to be fairly slow, and you can probably get the same effect by always having a wrapper element and changing its class rather than adding or removing it.
However, the performance issues you are seeing are most likely in your css:
3D transforms can be much faster than 2D due to hardware acceleration. It looks like you already have this, though you do need to be careful about which elements it is applied to
Shadows have real performance issues, especially when animated. Removing them will probably fix most of the slowness.
Rearranging background images can help - A single background image under transparent pages is faster than having a background image for each page.