godot: High CPU usage, time spent in texture updating
Godot version:
Any Godot 3.1 alpha
OS/device including version:
Issue description:
I’m using Godot in a project where a lot of sprites are packed into a spritesheet and many .tres files generated and then used for creating TextureAtlases. All went well until today I noticed the IDE became highly unresponsive. Activity Monitor shows 100% CPU usage. I investigated a bit and found out most time it’s doing this:
thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGSTOP
frame #0: 0x00000001029d096a godot.osx.tools.64`PoolVector<unsigned char>::resize(int) [inlined] operator new(p_size=1, p_pointer=0x000000017c1ab6ba, check=1, p_description="") at memory.h:104
frame #1: 0x00000001029d0966 godot.osx.tools.64`PoolVector<unsigned char>::resize(this=0x00007fff5fbfe118, p_size=134217728) at dvector.h:589
* frame #2: 0x0000000100c5d7cf godot.osx.tools.64`RasterizerStorageGLES3::texture_get_data(this=0x0000000108060a10, p_texture=RID @ 0x00007fff5fbfe170, p_layer=0) const at rasterizer_storage_gles3.cpp:1054
frame #3: 0x00000001027d447b godot.osx.tools.64`VisualServerRaster::texture_get_data(this=0x0000000106b38990, arg1=RID @ 0x00007fff5fbfe1b8, arg2=0) const at visual_server_raster.h:153
frame #4: 0x000000010282fa5b godot.osx.tools.64`CommandQueueMT::CommandRet2<VisualServer, Ref<Image> (VisualServer::*)(RID, int) const, RID, int, Ref<Image> >::call(this=0x00000001124e5570) at command_queue_mt.h:307
frame #5: 0x000000010282d987 godot.osx.tools.64`CommandQueueMT::flush_one(this=0x00000001124c5128, p_lock=false) at command_queue_mt.h:425
frame #6: 0x0000000102815b64 godot.osx.tools.64`CommandQueueMT::flush_all(this=0x00000001124c5128) at command_queue_mt.h:465
frame #7: 0x0000000102815c0f godot.osx.tools.64`VisualServerWrapMT::sync(this=0x00000001124c5010) at visual_server_wrap_mt.cpp:90
frame #8: 0x00000001000497fd godot.osx.tools.64`Main::iteration() at main.cpp:1867
frame #9: 0x000000010000fd7e godot.osx.tools.64`OS_OSX::run(this=0x00007fff5fbfe640) at os_osx.mm:2564
frame #10: 0x0000000100017698 godot.osx.tools.64`main(argc=4, argv=0x00007fff5fbff998) at godot_main_osx.mm:100
frame #11: 0x00007fffcace9235 libdyld.dylib`start + 1
frame #12: 0x00007fffcace9235 libdyld.dylib`start + 1
So, basically it reallocates the memory for the large texture (6MB) all the time, thus the CPU usage:
frame #2: 0x0000000100c5d7cf godot.osx.tools.64`RasterizerStorageGLES3::texture_get_data(this=0x0000000108060a10, p_texture=RID @ 0x00007fff5fbfe170, p_layer=0) const at rasterizer_storage_gles3.cpp:1054
1051
1052 int data_size = Image::get_image_data_size(texture->alloc_width, texture->alloc_height, real_format, texture->mipmaps > 1);
1053
-> 1054 data.resize(data_size * 2); //add some memory at the end, just in case for buggy drivers
1055 PoolVector<uint8_t>::Write wb = data.write();
1056
1057 glActiveTexture(GL_TEXTURE0);
Deleting the texture from the project helps. I’m not sure what is causing this.
Steps to reproduce:
Minimal reproduction project:
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (14 by maintainers)
Closing per the above comments.