2015-05-22 121 views
-1

我正在實現一個映射服務,我使用opengl來渲染3d建築物。我使用glfw來獲取opengl上下文。在映射服務中,當有請求獲取tile時,程序會創建一個不可見的GLFWwindow,並使用glfwMakeContextCurrent使其處於最新狀態。映射核心是用C++編寫的,並且封裝到nodejs,映射服務是一個nodejs應用程序。當有很多的要求,該節點的過程會崩潰,並顯示以下錯誤消息:GLFW崩潰節點進程

Process:    node [18015] 
Path:     /usr/local/bin/node 
Identifier:   node 
Version:    ??? 
Code Type:    X86-64 (Native) 
Parent Process:  node [18010] 
Responsible:   Terminal [682] 
User ID:    501 

Date/Time:    2015-05-22 14:46:07.665 +0800 
OS Version:   Mac OS X 10.10.3 (14D136) 
Report Version:  11 
Anonymous UUID:  F6351CBD-E434-9570-1B79-B6E999DE965F 


Time Awake Since Boot: 14000 seconds 

Crashed Thread:  6 

Exception Type:  EXC_BREAKPOINT (SIGTRAP) 
Exception Codes:  0x0000000000000002, 0x0000000000000000 

Thread 0:: Dispatch queue: com.apple.main-thread 
0 libsystem_kernel.dylib   0x00007fff885b521a kevent + 10 
1 node       0x000000010043ce89 uv_run + 239 
2 node       0x00000001003f766a node::Start(int, char**) + 365 
3 node       0x0000000100001374 start + 52 

Thread 1: 
0 libsystem_kernel.dylib   0x00007fff885af4de mach_msg_trap + 10 
1 libsystem_kernel.dylib   0x00007fff885ae64f mach_msg + 55 
2 com.apple.CoreFoundation  0x00007fff92bc0eb4 __CFRunLoopServiceMachPort + 212 
3 com.apple.CoreFoundation  0x00007fff92bc037b __CFRunLoopRun + 1371 
4 com.apple.CoreFoundation  0x00007fff92bbfbd8 CFRunLoopRunSpecific + 296 
5 com.apple.CoreFoundation  0x00007fff92c77671 CFRunLoopRun + 97 
6 node       0x0000000100447f1f uv__cf_loop_runner + 67 
7 node       0x000000010043c54a uv__thread_start + 25 
8 libsystem_pthread.dylib   0x00007fff879e1268 _pthread_body + 131 
9 libsystem_pthread.dylib   0x00007fff879e11e5 _pthread_start + 176 
10 libsystem_pthread.dylib   0x00007fff879df41d thread_start + 13 

Thread 2:: Dispatch queue: com.apple.libdispatch-manager 
0 libsystem_kernel.dylib   0x00007fff885b5232 kevent64 + 10 
1 libdispatch.dylib    0x00007fff8d91ca6a _dispatch_mgr_thread + 52 

Thread 3:: SamplerThread 
0 libsystem_kernel.dylib   0x00007fff885af51a semaphore_wait_trap + 10 
1 node       0x00000001003ed7f8 v8::internal::MacOSSemaphore::Wait() + 24 
2 node       0x00000001002fba49 v8::internal::RuntimeProfilerRateLimiter::SuspendIfNecessary() + 121 
3 node       0x00000001003ed8c8 v8::internal::SamplerThread::Run() + 88 
4 node       0x00000001003ed08c v8::internal::ThreadEntry(void*) + 60 
5 libsystem_pthread.dylib   0x00007fff879e1268 _pthread_body + 131 
6 libsystem_pthread.dylib   0x00007fff879e11e5 _pthread_start + 176 
7 libsystem_pthread.dylib   0x00007fff879df41d thread_start + 13 

Thread 4: 
0 libsystem_kernel.dylib   0x00007fff885b4136 __psynch_cvwait + 10 
1 node       0x0000000100445578 uv_cond_wait + 9 
2 node       0x0000000100445dfc worker + 207 
3 node       0x000000010043c54a uv__thread_start + 25 
4 libsystem_pthread.dylib   0x00007fff879e1268 _pthread_body + 131 
5 libsystem_pthread.dylib   0x00007fff879e11e5 _pthread_start + 176 
6 libsystem_pthread.dylib   0x00007fff879df41d thread_start + 13 

Thread 5: 
0 org.gdal.gdal     0x000000010486fb4e SHPReadObject + 2698 
1 org.gdal.gdal     0x00000001047f7e41 OGRShapeLayer::FetchShape(int) + 45 
2 org.gdal.gdal     0x00000001047f7ff4 OGRShapeLayer::GetNextFeature() + 238 
3 org.gdal.gdal     0x0000000104778e1d OGRLayer::GetFeatureCount(int) + 37 
4 org.gdal.gdal     0x00000001047f8ef9 OGRShapeLayer::GetFeatureCount(int) + 235 
5 mapping.node     0x0000000103a38cbb map::OGRDataSourceWrapper::GetLayer(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, int) + 2347 (ogr_data_source.cpp:111) 
6 mapping.node     0x0000000103a07e02 map::Map::Render__(map::Map::DrawType) + 1490 (map.cpp:271) 
7 mapping.node     0x0000000103a07267 map::Map::Render() + 647 (map.cpp:116) 
8 mapping.node     0x00000001039cb966 MappingWrapper::renderWorker(uv_work_s*) + 22 (mapping_wrapper.cc:542) 
9 node       0x0000000100445d87 worker + 90 
10 node       0x000000010043c54a uv__thread_start + 25 
11 libsystem_pthread.dylib   0x00007fff879e1268 _pthread_body + 131 
12 libsystem_pthread.dylib   0x00007fff879e11e5 _pthread_start + 176 
13 libsystem_pthread.dylib   0x00007fff879df41d thread_start + 13 

Thread 6 Crashed: 
0 com.apple.CoreFoundation  0x00007fff92cb5744 getAtomTarget + 84 
1 com.apple.CoreFoundation  0x00007fff92bfaad2 ___forwarding___ + 178 
2 com.apple.CoreFoundation  0x00007fff92bfa998 _CF_forwarding_prep_0 + 120 
3 mapping.node     0x0000000103d5b482 _glfwPlatformMakeContextCurrent + 50 
4 mapping.node     0x0000000103d5baf8 glfwCreateWindow + 712 
5 mapping.node     0x0000000103a2d718 map::OpenGLRender::InitOpenGL() + 40 (opengl_render.cpp:289) 
6 mapping.node     0x0000000103a2d618 map::OpenGLRender::Init(boost::shared_ptr<map::MapStyle>) + 24 (opengl_render.cpp:281) 
7 mapping.node     0x0000000103a074aa map::Map::Render() + 1226 (map.cpp:152) 
8 mapping.node     0x00000001039cb966 MappingWrapper::renderWorker(uv_work_s*) + 22 (mapping_wrapper.cc:542) 
9 node       0x0000000100445d87 worker + 90 
10 node       0x000000010043c54a uv__thread_start + 25 
11 libsystem_pthread.dylib   0x00007fff879e1268 _pthread_body + 131 
12 libsystem_pthread.dylib   0x00007fff879e11e5 _pthread_start + 176 
13 libsystem_pthread.dylib   0x00007fff879df41d thread_start + 13 

Thread 7: 
0 libsystem_kernel.dylib   0x00007fff885b4136 __psynch_cvwait + 10 
1 node       0x0000000100445578 uv_cond_wait + 9 
2 node       0x0000000100445dfc worker + 207 
3 node       0x000000010043c54a uv__thread_start + 25 
4 libsystem_pthread.dylib   0x00007fff879e1268 _pthread_body + 131 
5 libsystem_pthread.dylib   0x00007fff879e11e5 _pthread_start + 176 
6 libsystem_pthread.dylib   0x00007fff879df41d thread_start + 13 

Thread 8: 
0 libsystem_kernel.dylib   0x00007fff885b494a __workq_kernreturn + 10 
1 libsystem_pthread.dylib   0x00007fff879df40d start_wqthread + 13 

Thread 9: 
0 libsystem_kernel.dylib   0x00007fff885b494a __workq_kernreturn + 10 
1 libsystem_pthread.dylib   0x00007fff879df40d start_wqthread + 13 

Thread 10: 
0 libsystem_kernel.dylib   0x00007fff885b494a __workq_kernreturn + 10 
1 libsystem_pthread.dylib   0x00007fff879df40d start_wqthread + 13 

Thread 11: 
0 libsystem_kernel.dylib   0x00007fff885b494a __workq_kernreturn + 10 
1 libsystem_pthread.dylib   0x00007fff879df40d start_wqthread + 13 

Thread 6 crashed with X86 Thread State (64-bit): 
    rax: 0x0000000000000000 rbx: 0x000000000c000000 rcx: 0x0000000000000001 rdx: 0x000000019a05b2c0 
    rdi: 0x0000000c00000001 rsi: 0x0000000000000000 rbp: 0x000000010681caa0 rsp: 0x000000010681ca90 
    r8: 0x000000010681cb80 r9: 0x000000010681d000 r10: 0x0000000000000001 r11: 0x00007fff92bfa920 
    r12: 0x000000010681cb00 r13: 0x00007fff895930c0 r14: 0x0000000100d8aa50 r15: 0x000000010681cb00 
    rip: 0x00007fff92cb5744 rfl: 0x0000000000000287 cr2: 0x000000011888dd80 

Logical CPU:  2 
Error Code:  0x00000000 
Trap Number:  3 


Binary Images: 
     0x100000000 -  0x10068bfff +node (???) <500822CB-7EA6-34D2-98D6-BF45AF81E1CB> /usr/local/bin/node 
     0x100aec000 -  0x100afbfff libSimplifiedChineseConverter.dylib (64) <468DE6E1-42B9-3751-ACA5-7D16C550FF84> /System/Library/CoreServices/Encodings/libSimplifiedChineseConverter.dylib 
     0x100fc1000 -  0x100fc6fff +DTraceProviderBindings.node (0) <BCAA5EDB-BBF3-3556-98E6-6813F1A5BA72> /Users/USER/*/DTraceProviderBindings.node 
     0x100fcf000 -  0x100fd4fff +DTraceProviderBindings.node (0) <1A6ED61C-E715-382E-BF88-2BDA307A51B4> /Users/USER/*/DTraceProviderBindings.node 
     0x100fdd000 -  0x100fe1fff com.apple.agl (3.3.0 - AGL-3.3.0) <83B4076C-BD87-3436-B59F-65184128FEC1> /System/Library/Frameworks/AGL.framework/Versions/A/AGL 
     0x100fe8000 -  0x100fedfff com.apple.JavaVM (15.0.0 - 15.0.0) <67BD63C5-D82F-3A31-BC43-C8810356D524> /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM 
     0x1039c4000 -  0x103df3ff7 +mapping.node (0) <6CCCCAEB-7D48-38D8-8C21-287A5C7E88BA> /Users/USER/*/mapping.node 
     0x104174000 -  0x10424aff7 +org.osgeo.geos (3.4.2 - GEOS 3.4.3) <C28ECCD4-2212-3189-A25A-1A9BEFC07351> 
...... 

...... 

...... 

External Modification Summary: 
    Calls made by other processes targeting this process: 
    task_for_pid: 4 
    thread_create: 0 
    thread_set_state: 0 
    Calls made by this process: 
    task_for_pid: 0 
    thread_create: 0 
    thread_set_state: 0 
    Calls made by all processes on this machine: 
    task_for_pid: 17548 
    thread_create: 0 
    thread_set_state: 168 

VM Region Summary: 

ReadOnly portion of Libraries: Total=243.9M resident=93.0M(38%) 

swapped_out_or_unallocated=150.9M(62%) 

Writable regions: Total=1.2G written=174.7M(14%) resident=389.4M(32%) 

swapped_out=473.2M(39%) unallocated=830.0M(68%) 

REGION TYPE      VIRTUAL 

===========      ======= 

CG shared images     4528K 

CoreUI image data      4K 

Dispatch continuations    8192K 

IOKit        882.6M 

Kernel Alloc Once      8K 

MALLOC       277.4M 

MALLOC (admin)      32K 

MALLOC_LARGE (reserved)   3768K  reserved VM address space 
(unallocated) 
Memory Tag 255     552.5M 

Memory Tag 255 (reserved)   1920K  reserved VM address space 
(unallocated) 
STACK GUARD      56.0M 

Stack        12.7M 

VM_ALLOCATE      14.4M 

__DATA        19.6M 

__GLSLBUILTINS      2588K 

__IMAGE        528K 

__LINKEDIT       85.2M 

__TEXT       158.6M 

__UNICODE       552K 

mapped file      207.2M 

shared memory      68K 

===========      ======= 

TOTAL        2.2G 

TOTAL, minus reserved VM space  2.2G 

回答

0

這真的很難說是怎麼回事。但是既然你提到這種情況發生在高負荷下,我們可以猜測一下。可能發生的情況是,您只是用完了可用的系統資源。創建一個窗口會觸發一系列的分配,如果在短時間內發生的分配太多,這些分配可能會失敗或更糟,會觸發一些錯誤。

我的建議:不要爲每個圖塊創建一個OpenGL。在進程開始時創建一個窗口,並使用一堆用於繪製切片的渲染緩衝區/紋理。然後在每個請求中將瓦片繪製到預先分配的資源中,然後爲下一個瓦片保留資源。甚至不打算嘗試多線程渲染; OpenGL的驅動程序已經在你的內部完成了,驅動程序開發人員已經把它幹掉了;充其量你不會放慢整個事情。只需連續處理渲染請求。優化將集中於對渲染進行排序,以便渲染拼貼所需的資源將合併該拼貼的渲染。