OpenWebRTC iOS 随机崩溃 gstglcontext

OpenWebRTC iOS random crash gstglcontext

我正在从事 WebRTC 项目。我选择了OpenWebRTC在我的项目中实现。

我已经让它同时适用于网络和 iOS。我在 asp.net MVC 中开发了一个信令服务器,并使用 coTurn 服务器作为转弯服务器。

除一个问题外,一切正常。

iOS 应用随机崩溃,出现异常

EXC_BAD_ACCESS exception:(gstglcontext(14):EXC_BAD_ACCESS (code=1,address=0x30))

异常是从 SDK 中的某处抛出的。几天来我一直在努力寻找解决方案,但到目前为止还没有成功。

有没有其他人遇到过类似的问题?

以下是崩溃的设备日志中的堆栈跟踪

Incident Identifier: FA4FC9DB-B4CA-497E-9A25-639A4F743BC8
CrashReporter Key:   ff7120b6353817347fd122932620c25469ace55e
Hardware Model:      iPad4,5
Process:             NativeDemo [983]
Path:                /private/var/containers/Bundle/Application/13129A20-974B-405C-AB44-B5F8526AF362/NativeDemo.app/NativeDemo
Identifier:          com.ericsson.research.owr.NativeDemo
Version:             1 (1.0)
Code Type:           ARM-64 (Native)
Role:                Foreground
Parent Process:      launchd [1]
Coalition:           com.ericsson.research.owr.NativeDemo [1284]


Date/Time:           2017-03-22 04:52:45.7874 -0700
Launch Time:         2017-03-22 04:26:17.7434 -0700
OS Version:          iPhone OS 10.2.1 (14D27)
Report Version:      104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000030
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]
Triggered by Thread:  9

Filtered syslog:
None found

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   GraphicsServices                0x000000018fd7e198 GSEventRunModal + 180
6   UIKit                           0x000000019430a7fc -[UIApplication _run] + 684
7   UIKit                           0x0000000194305534 UIApplicationMain + 208
8   NativeDemo                      0x0000000100050e90 0x100040000 + 69264
9   libdyld.dylib                   0x000000018d2ad5b8 start + 4

Thread 1 name:  owr_main_loop
Thread 1:
0   libsystem_kernel.dylib          0x000000018d3a56e4 poll + 8
1   NativeDemo                      0x000000010031d8c0 0x100040000 + 3004608
2   NativeDemo                      0x000000010031dc18 0x100040000 + 3005464
3   NativeDemo                      0x000000010059794c 0x100040000 + 5601612
4   NativeDemo                      0x0000000100597a88 0x100040000 + 5601928
5   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
6   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
7   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
8   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 2 name:  AVAudioSession Notify Thread
Thread 2:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   AVFAudio                        0x00000001a7867d24 GenericRunLoopThread::Entry(void*) + 164
6   AVFAudio                        0x00000001a788dd9c CAPThread::Entry(CAPThread*) + 84
7   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
8   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
9   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 3 name:  com.apple.uikit.eventfetch-thread
Thread 3:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   Foundation                      0x000000018ee0726c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 304
6   Foundation                      0x000000018ee27dd0 -[NSRunLoop(NSRunLoop) runUntilDate:] + 96
7   UIKit                           0x0000000194c7ec38 -[UIEventFetcher threadMain] + 136
8   Foundation                      0x000000018ef04e68 __NSThread__start__ + 1024
9   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
10  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
11  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 4 name:  com.apple.NSURLConnectionLoader
Thread 4:
0   libsystem_kernel.dylib          0x000000018d3a1188 mach_msg_trap + 8
1   libsystem_kernel.dylib          0x000000018d3a0ff8 mach_msg + 72
2   CoreFoundation                  0x000000018e39e5d0 __CFRunLoopServiceMachPort + 192
3   CoreFoundation                  0x000000018e39c1ec __CFRunLoopRun + 1132
4   CoreFoundation                  0x000000018e2ca2b8 CFRunLoopRunSpecific + 444
5   CFNetwork                       0x000000018eacfa70 +[NSURLConnection(Loader) _resourceLoadLoop:] + 336
6   Foundation                      0x000000018ef04e68 __NSThread__start__ + 1024
7   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
8   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
9   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 5 name:  gmain
Thread 5:
0   libsystem_kernel.dylib          0x000000018d3a56e4 poll + 8
1   NativeDemo                      0x000000010031d8c0 0x100040000 + 3004608
2   NativeDemo                      0x000000010031d994 0x100040000 + 3004820
3   NativeDemo                      0x000000010031ecec 0x100040000 + 3009772
4   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
5   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
6   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
7   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 6 name:  video-source:src
Thread 6:
0   libsystem_kernel.dylib          0x000000018d3bee1c __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018d4849f4 _pthread_cond_wait + 692
2   Foundation                      0x000000018ee11f28 -[NSCondition waitUntilDate:] + 340
3   Foundation                      0x000000018ee0ef24 -[NSConditionLock lockWhenCondition:beforeDate:] + 256
4   NativeDemo                      0x0000000100070894 0x100040000 + 198804
5   NativeDemo                      0x0000000100071b44 0x100040000 + 203588
6   NativeDemo                      0x000000010040ce74 0x100040000 + 3985012
7   NativeDemo                      0x000000010040c678 0x100040000 + 3982968
8   NativeDemo                      0x00000001004886a8 0x100040000 + 4490920
9   NativeDemo                      0x0000000100303e24 0x100040000 + 2899492
10  NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
11  libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
12  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
13  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 7 name:  sink-queue-0:src
Thread 7:
0   libsystem_kernel.dylib          0x000000018d3bee1c __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018d4849c0 _pthread_cond_wait + 640
2   NativeDemo                      0x000000010036a1d0 0x100040000 + 3318224
3   NativeDemo                      0x0000000100099c40 0x100040000 + 367680
4   NativeDemo                      0x00000001004886a8 0x100040000 + 4490920
5   NativeDemo                      0x0000000100303e24 0x100040000 + 2899492
6   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
7   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
8   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
9   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 8 name:  gstglnavigation
Thread 8:
0   libsystem_kernel.dylib          0x000000018d3a56e4 poll + 8
1   NativeDemo                      0x000000010031d8c0 0x100040000 + 3004608
2   NativeDemo                      0x000000010031dc18 0x100040000 + 3005464
3   NativeDemo                      0x000000010043ba28 0x100040000 + 4176424
4   NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
5   libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
6   libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
7   libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 9 name:  gstglcontext
Thread 9 Crashed:
0   IOAccelerator                   0x000000019097ecbc IOAccelResourceGetResidentDataSize + 0
1   AGXGLDriver                     0x00000001a2901390 0x1a289a000 + 422800
2   AGXGLDriver                     0x00000001a28c1354 0x1a289a000 + 160596
3   AGXGLDriver                     0x00000001a28c14bc 0x1a289a000 + 160956
4   AGXGLDriver                     0x00000001a28bee38 0x1a289a000 + 151096
5   GLEngine                        0x00000001a303b81c glClear_Exec + 432
6   NativeDemo                      0x00000001000d3340 0x100040000 + 602944
7   NativeDemo                      0x000000010043f8a8 0x100040000 + 4192424
8   NativeDemo                      0x000000010043ccb8 0x100040000 + 4181176
9   NativeDemo                      0x000000010043ccf8 0x100040000 + 4181240
10  NativeDemo                      0x000000010031d5e4 0x100040000 + 3003876
11  NativeDemo                      0x000000010031d924 0x100040000 + 3004708
12  NativeDemo                      0x000000010031dc18 0x100040000 + 3005464
13  NativeDemo                      0x0000000100437f48 0x100040000 + 4161352
14  NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
15  libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
16  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
17  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

Thread 10 name:  source-output-queue-0:src
Thread 10:
0   libsystem_kernel.dylib          0x000000018d3bee1c __psynch_cvwait + 8
1   libsystem_pthread.dylib         0x000000018d4849c0 _pthread_cond_wait + 640
2   NativeDemo                      0x000000010036a1d0 0x100040000 + 3318224
3   NativeDemo                      0x000000010043ca84 0x100040000 + 4180612
4   NativeDemo                      0x000000010043bde4 0x100040000 + 4177380
5   NativeDemo                      0x00000001000d417c 0x100040000 + 606588
6   NativeDemo                      0x00000001000d2540 0x100040000 + 599360
7   NativeDemo                      0x0000000100403f48 0x100040000 + 3948360
8   NativeDemo                      0x0000000100407524 0x100040000 + 3962148
9   NativeDemo                      0x0000000100472894 0x100040000 + 4401300
10  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
11  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
12  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
13  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
14  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
15  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
16  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
17  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
18  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
19  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
20  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
21  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
22  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
23  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
24  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
25  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
26  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
27  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
28  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
29  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
30  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
31  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
32  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
33  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
34  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
35  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
36  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
37  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
38  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
39  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
40  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
41  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
42  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
43  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
44  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
45  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
46  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
47  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
48  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
49  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
50  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
51  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
52  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
53  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
54  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
55  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
56  NativeDemo                      0x00000001003f78e4 0x100040000 + 3897572
57  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
58  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
59  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
60  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
61  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
62  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
63  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
64  NativeDemo                      0x000000010049b000 0x100040000 + 4567040
65  NativeDemo                      0x0000000100472894 0x100040000 + 4401300
66  NativeDemo                      0x00000001004732b8 0x100040000 + 4403896
67  NativeDemo                      0x00000001004730f4 0x100040000 + 4403444
68  NativeDemo                      0x000000010009a014 0x100040000 + 368660
69  NativeDemo                      0x00000001004886a8 0x100040000 + 4490920
70  NativeDemo                      0x0000000100303e24 0x100040000 + 2899492
71  NativeDemo                      0x0000000100307d90 0x100040000 + 2915728
72  libsystem_pthread.dylib         0x000000018d485850 _pthread_body + 240
73  libsystem_pthread.dylib         0x000000018d485760 _pthread_body + 0
74  libsystem_pthread.dylib         0x000000018d482d94 thread_start + 4

我进一步追踪了这个问题。

函数'gst_glimage_sink_on_draw'

中gstglimagesink.c的下面一行抛出异常
gl->Clear (GL_COLOR_BUFFER_BIT);
gl->Clear (GL_COLOR_BUFFER_BIT);

在那一行 gl 是类型 GstGLFuncs 的虚拟转换 table。 GstGLFuncs 是包含用户数据的 struct GstGLContext 类型的成员。

很明显,您没有要访问的用户数据。您有 Dangling pointer。这可能是因为

  1. 指针(在你的例子中 GstGLContext)曾经指向内存是好的,但它的块是 释放。
  2. 指针已损坏。

您的应用程序崩溃的代码行不是问题的根本原因。 #1 中的问题是导致过早释放的代码行,#2 中的问题是损坏指针的代码行。

将 gstreamer 库更新到版本 1.10.4。较新版本的 gstreamer 已修复此错误。更新修改脚本 'update-gst.sh' 如下 master_commit=git ls-remote git://anongit.freedesktop.org/git/gstreamer/$i | grep "1.10.4$" | awk '{print }'

然后是 运行 脚本,之后首先为 os x 进行干净构建,然后是 iOS.