Prevent "program not responding"

Hi,

I have a scene which I build up in a parallel thread and meahwhile show a loading screen. Everything is fine but when I (in the original thread) attach the built up node to the root node it takes a lot of processing to (I guess) calculate for jmonkey the scenegraph and even if I hid my cursor to prevent the user clicking the windows loading symbol appears and if I click or press a button it shows the program not responding message.

The question is how could I prevent that (I don’t know if I can somehow force out frames while processing the scenegraph) and that if i click while the not responding message happens then it won’t finish ever loading (CPU usage is 0% and seems like the process just died), so why does this happen?

Thanks a lot!

Well possible reasons are ususally uploading stuff to the graficcard, and generating mipmaps.

-> If you use any other format than dds, and a texturefilter set (u have per default, and you ebetter leave it on) the gpu/driver has to create mipmaps on the fly, for larger textures or a large amount this takes time.
-> Uploading large images /meshes ect can also take some time
-> Compiling shaders might also need to be done.

-> Solution, make a queue for loaded objects, then only attach one additional per frame, repeat till queue is empty that way there are hoepfulle enough frames in between so that windows recognizes the app as working.

ps. microsoft itself sucks at preventing this, outlook on my work computer does it nearly always when starting.

@Empire Phoenix said: Well possible reasons are ususally uploading stuff to the graficcard, and generating mipmaps.

-> If you use any other format than dds, and a texturefilter set (u have per default, and you ebetter leave it on) the gpu/driver has to create mipmaps on the fly, for larger textures or a large amount this takes time.
-> Uploading large images /meshes ect can also take some time
-> Compiling shaders might also need to be done.

-> Solution, make a queue for loaded objects, then only attach one additional per frame, repeat till queue is empty that way there are hoepfulle enough frames in between so that windows recognizes the app as working.

ps. microsoft itself sucks at preventing this, outlook on my work computer does it nearly always when starting.

Hey, thanks for your input!

I use DDS but get this all the time:
“dec. 04, 2013 1:09:30 DU com.jme3.texture.plugins.DDSLoader loadHeader
WARNING: Got 1 mipmaps, expected 14”

How can I pre-generate the mipmaps?

You might also want to think about intercepting those clicks. Something similar to:

[java]
if (!busyLoading) {
// Do things normally
} else {
// make a sound to tell user it’s not ready (low Hz sound is often tied to “denied” in people’s brain)
// Or whatever could be suitable. Maybe a quick and dirty BitmapText in middle of the screen would work.
}
[/java]

Depending on the reason of the unresponsiveness, the above might work without a problem. Or not. From what I understand the above shouldn’t be a problem.

@madjack said: You might also want to think about intercepting those clicks. Something similar to:

[java]
if (!busyLoading) {
// Do things normally
} else {
// make a sound to tell user it’s not ready (low Hz sound is often tied to “denied” in people’s brain)
// Or whatever could be suitable. Maybe a quick and dirty BitmapText in middle of the screen would work.
}
[/java]

Depending on the reason of the unresponsiveness, the above might work without a problem. Or not. From what I understand the above shouldn’t be a problem.

I have a loading screen that tells the user that be patient, the application is loading, but the problem is that if the user despite my warning still clicks it triggers Windows’ “program not responding” window and after that for some reason even if I select “wait for program to respond” it won’t do anything (the screen goes white and the application stops working).

@jadam said: I have a loading screen that tells the user that be patient,

Exactly why I’m suggesting that. People are not patient. Even though they were, what happens if I accidentally click it? You can also be sure that if it says to be patient and wait, people will click it just to be contrarian; just to see what will happen.

Just intercept the call. It’s only a true/false thing and will save everyone lots of grieving.

@madjack said: Exactly why I'm suggesting that. People are not patient. Even though they were, what happens if I accidentally click it? You can also be sure that if it says to be patient and wait, people will click it just to be contrarian; just to see what will happen.

Just intercept the call. It’s only a true/false thing and will save everyone lots of grieving.


How can you intercept the click? Also, I was wondering if I could just temporarily disable input at the inputmanager somehow?

Well actuall if you just wiat, it will work, but its not nice that users see that.

U need to generate the mipmaplayers with an external program capable of doing so. There are some from ati and nvidia that can do batches.

@jadam said: How can you intercept the click? Also, I was wondering if I could just temporarily disable input at the inputmanager somehow?

It’s your game/application. I have no idea how you’re set up. :stuck_out_tongue: But, where you would do something when users clicked, you can intercept that. Alternatively disabling the inputManager would work also.

@madjack said: It's your game/application. I have no idea how you're set up. :P But, where you would do something when users clicked, you can intercept that. Alternatively disabling the inputManager would work also.

I could not find out how could I disable the inputmanager temporarily, do you know how?

Do you even use an ActionListener or AnalogueListener? Is your game even reacting on clicks?

I’m asking because it seems the more I read the less it looks like it to me.

Last thing, how long does it take to get the game to work fully? This might be a threading problem if it goes on for a “long” time. I’m not saying this isn’t mipmaps, but I prefer being certain before making changes.

Yes, of course, I have both analog listener and action listener in different places of the application.

It took a couple of minutes to load, but now as I did the mipmaps the problem is solved, it does not have the time to go to “program not responding”.

By the way, is it possible to turn off the inputmanager for a while?

Disableing the input manager won’t help or similar stuff.
Its a windows os level thing. If there is no frame renderd for x seconds the window is grayed out.

The only thing you can do to prevent this, is render a frame every few seconds.

So devide the total load time betweena few frames.
If you have one thing single thing that needs very long, you need to rethink on how to split it into multiple parts, or do it in the background.

The mipmap calculations is just on of the problems, and might be enough if the rest is fast.
Another could be the loading of models/audio/textures in the render thread. In that case a ThreadPoolExecutor that gets load/precache tasks, and enques the results are a solution.

Basically the only things that must be in the renderthread are:
Uploading textures, done automatically by jme the first frame a new texture is displayed -> Solution in the background while still loading attach not everything at once, but only one per frame, to reduce the work per frame.

Uploading meshes, usually very fast, but for very large might needs some time, same solution as for textures.

Compiling shaders, same as textures, possible trick, creata a quad and let it only use one shader, that way you do not have to compile all shaders for a whole model the same time the textures and the mesh are uploaded, as a quad is as simple as it gets.

Well and rendering of course, but if you manage to slow the normal rendering down to a point where you get the not responding between every frame, you should start optimizing that first.

EDIT: hm to late, already solved :slight_smile:

Guys thanks a lot for the input and really the mipmaps generation sped it up so it does not go “not responding”!

Empire Phoenix is correct, it’s the operating system flagging the application as “not responding”, not jmonkey. It may be working ok for you now, but the problem still remains that you are doing too much per frame. As already suggested, use a queue and add one item per frame. That is the correct way to do it. It ensures that it will never happen (i.e. on other peoples computers with less power than yours) and will more than likely speed up loading time even more as a result of you not consuming the main loop all for yourself and halting all other pending operations.