WebRTC built for iOS. How to integrate into Xcode project

757 views
Skip to first unread message

you...@gmail.com

unread,
Jan 16, 2015, 12:29:16 PM1/16/15
to discuss...@googlegroups.com
Hi,

I have recently tried to update to the latest trunk (to be precise rev. 8059 from 6700) and now I am struggling to integrate WebRTC in my app.

I have followed instructions here http://www.webrtc.org/native-code/ios and was able to build AppRTCDemo app along with all the libraries it needs. I was also able to run it on device. I did it for armv7.
After that I inspected AppRTCDemo target in .gyp file and tried to add libjingle_peerconnection_objc.a and libjingle_peerconnection.a to my app. This approach failed on linking step.
Then I added all the necessary libraries from out_ios/Debug-iphoneos to my project and was finally able to build my app.

Now I get crashes like this:

* thread #9: tid = 0xb3085, 0x01000000 MyApp, stop reason = EXC_BAD_ACCESS (code=2, address=0x1000000)
    frame #0: 0x01000000 MyApp
  * frame #1: 0x007652d0 MyApp`rtc::MessageQueue::Get(this=0x1558f370, pmsg=0x048eaf5c, cmsWait=-1, process_io=true) + 1392 at messagequeue.cc:253
    frame #2: 0x007930e4 MyApp`rtc::Thread::ProcessMessages(this=0x1558f370, cmsLoop=-1) + 116 at thread.cc:562
    frame #3: 0x00793052 MyApp`rtc::Thread::Run(this=0x1558f370) + 34 at thread.cc:404
    frame #4: 0x00792ea6 MyApp`rtc::Thread::PreRun(pv=0x15586f20) + 90 at thread.cc:396
    frame #5: 0x2f997e92 libsystem_pthread.dylib`_pthread_body + 138
    frame #6: 0x2f997e06 libsystem_pthread.dylib`_pthread_start + 118

when I try to create thread like this from main thread:
    rtc::Thread *myWorkerThread = new rtc::Thread();
    myWorkerThread->SetName("My_worker_thread", myWorkerThread);
    myWorkerThread->Start();

I am not sure if this happens because of some problems in my app or in how I add webrtc to my project or the way I have built webrtc.

Could anyone please share how you work with new releases (>6700) of WebRTC on iOS? Do you manually add built all static libs into project (build phases -> link binary with libraries) or there is a way to create an umbrella library and add only that to project? Did someone have the same problems like I do?

RTC.Blacker

unread,
Jan 16, 2015, 8:25:29 PM1/16/15
to discuss...@googlegroups.com
have you test AppRTCDemo, is it ok?

you...@gmail.com

unread,
Jan 19, 2015, 4:53:48 AM1/19/15
to discuss...@googlegroups.com
Yes. AppRTCDemo works fine. I have built it using instructions for Xcode. I can connect to server and see video on both desktop and iPhone. I have built it fro armv7.

you...@gmail.com

unread,
Jan 19, 2015, 6:41:48 AM1/19/15
to discuss...@googlegroups.com
I have just tried to build my project using the clang shipped with WebRTC. I still get the same crashes. Please see image attached.
I am not sure if I should file a bug to WebRTC issues tracker since it works fine with AppRTCDemo app.

I would appreciate any help on this issue.
Screen Shot 2015-01-19 at 11.49.56.png
Message has been deleted
Message has been deleted

you...@gmail.com

unread,
Jan 19, 2015, 12:29:07 PM1/19/15
to discuss...@googlegroups.com
Ok, I am a bit desperate now.
I have spent the whole day today trying to make it work:
0. I have made a test project which just creates thread in AppDelegate in applicationDidFinishLaunching:withOptions: (attached without libs and webrtc) in case my project introduces side effects.
1. I have tried building test app with compiler downloaded with WebRTC.
2. I have tried to build WebRTC with clang from Xcode.
3. I have tried to setup Xcode project to have all the same compiler flags as WebRTC does.

None of this works. I still crash mostly in the same place.

At this point in time it seems to me that there is some stupid mistake somewhere or I am missing something obvious.
test_webrtc_ios_libs.zip

Zeke Chin

unread,
Jan 20, 2015, 3:57:15 PM1/20/15
to discuss...@googlegroups.com
Can you try with HEAD @ 8104?

--

---
You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss-webrt...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

you...@gmail.com

unread,
Jan 21, 2015, 3:27:20 AM1/21/15
to discuss...@googlegroups.com
I found the issue yesterday.
I wrote a comment to the issue 4202 in tracker https://code.google.com/p/webrtc/issues/detail?id=4202

The problem was in _DEBUG macro which I didn't add to my project. Because of this macro I was creating rtc::Thread object which was 4 bytes smaller than the one from library which was messing up memory.

I believe it might be a good idea to make some kind of export settings and headers script or at least readme file for WebRTC in order to avoid similar issues in future.

Zeke Chin

unread,
Jan 21, 2015, 2:19:08 PM1/21/15
to discuss...@googlegroups.com
Cool, glad solution was discovered.

you...@gmail.com

unread,
Jan 22, 2015, 3:59:00 AM1/22/15
to discuss...@googlegroups.com
Yeah, it took quite some man-hours.

BTW, thanks for taking a look.

studyro zhang

unread,
Mar 24, 2015, 9:22:44 AM3/24/15
to discuss...@googlegroups.com
The issue just happened to me. It would take me forever to find the key point. Thank you for sharing your solution.

On Saturday, January 17, 2015 at 1:29:16 AM UTC+8, you...@gmail.com wrote:

Brandon Tyler

unread,
Sep 11, 2017, 5:15:33 PM9/11/17
to discuss-webrtc
Hello!  Would you mind explaining how you added this debug macro to your project?  I read your other post, but I'm still unclear as to how or where I should add this.  I'm getting a weird threading crash as well that begins in a thread inside the critical section.  I would be so appreciative if you could explain where and what to add to the debug macro.

kthel...@webrtc.org

unread,
Sep 12, 2017, 2:50:32 AM9/12/17
to discuss-webrtc
Brandon, this thread is several years old and information in it is likely to be very out of date. Please file a bug over at https://bugs.chromium.org/p/webrtc/issues/list or start a new thread and describe your issue in detail. Thanks!
Reply all
Reply to author
Forward
0 new messages