i noticed that since a while, my jme project needs much more time to start.
well, after doing some rudimentay benchmarks, i put a breakpoint in TextureManager at the line where the cached textures are returned and started the app in debug mode. the unpleasant part was that while i use some textures multiple times, no "cache hit" happened, and the breakpoint wasn't reached. the obvious disadvantage is that textures are reloaded each time.
the problem is in TextureManager.loadTexture(TextureKey) :
TextureState state = null;
... // do some stff but don't touch 'state'
// the texture is cached only if 'state' isn't null (!)
if (state != null) {
state.setTexture(texture);
state.apply();
m_tCache.put(tkey, texture);
}
it would be nice if a developer would remove that 'state', pull m_tCache.put(tkey, texture); out of the if statement and then remove the if . that should fix it.
EDIT: stupid me! the statement in the code above is false, but i let in, so the post can be understood. the textures are cached, but somehow i never get a "cache hit".
i think we are in great need of some automated performance tests. running all the TestXXX programs are a great way to see if you have broken anything badly, but performance is often left behind…
some way of going through all the testprograms, firing them up, writing down how long their inits take, and then letting them run for 10-20 seconds and noting their average fps or something…and it should be something anyone could run, to see differences on their own computer…we could have a reference comp as well…then we build a nice database viewable from the net, and we got our own benchmark program s
i've done some automated tests like this before, when unit-testing is not enough…for our hockeygame we had problems with the puck going through the net sometimes(very seldom)…so i made a program that shot thousands of pucks from different angles as an automated test, so that we new right away if the collision code got broken…
i noticed that since a while, my jme project needs much more time to start.
well, after doing some rudimentay benchmarks, i put a breakpoint in TextureManager at the line where the cached textures are returned and started the app in debug mode. the unpleasant part was that while i use some textures multiple times, no "cache hit" happened, and the breakpoint wasn't reached. the obvious disadvantage is that textures are reloaded each time.
the problem is in TextureManager.loadTexture(TextureKey) :
TextureState state = null;
... // do some stff but don't touch 'state'
// the texture is cached only if 'state' isn't null (!)
if (state != null) {
state.setTexture(texture);
state.apply();
m_tCache.put(tkey, texture);
}
it would be nice if a developer would remove that 'state', pull m_tCache.put(tkey, texture); out of the if statement and then remove the if . that should fix it.
EDIT: stupid me! the statement in the code above is false, but i let in, so the post can be understood. the textures are cached, but somehow i never get a "cache hit".
help!
I think the fact that they need a TextureState is by design. For the cache to work the texture must already have it's id number. I subjected a fix on another thread, but it was ignored.
I don't see how this fixes sfera's problem. His textute is loaded and cached, but then when he tries to load it again, it's not recognized from the cache. If you want you can enlighten how your code helps solve this (it's not very clear to me).
If this is about multithreading, then you're in the wrong thread (and that has been discussed).
it would be nice if a developer would remove that 'state', pull m_tCache.put(tkey, texture); out of the if statement and then remove the if . that should fix it.
I think he wants his program loads fast again, using cached textures instead of reloading them each time. I don't see anything about removing anything related to state or TextureState??
He edited it while I was posting the first post so I did not see it. The rest of the posts were just validating why I posted it so I ignored the fact that it was crossed out.
i see the discussion is getting interesting (about "what sfera wants and what he doesn't" )
such a luck a certain frog didn't discover the topic yet :lol:
back to the topic:
i'd have one more question: can anyone confirm this issue? didn't anyone notice any slowdowns when they start their applications? (i mean only the start, not the app itself)
@badmi: sorry badmi, i'd like to try your code, but there are no setNext() nor SetLast() methods in Texture.
Regarding ignoring code changes, etc. Use the issue tracker… thing won't get "ignored" there, but it's very easy to lose a topic in the forum, or just plain forget about it.
Well his code was not ignored… it was just established there are several ways for fixing this problem. It has to do with multithreading, and not with this thread.