Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS video not working: errors with not allowed to load local resource and MediaStream #328

Closed
cdcv opened this issue Mar 20, 2018 · 24 comments
Milestone

Comments

@cdcv
Copy link

cdcv commented Mar 20, 2018

I have followed the instructions provided and created a video chat app. It works correctly in browser and Android cordova.
On iOS cordova, the self-video displays (so webRTC is working somewhat), but peer video does not display (on either the iOS device or a chrome web browser peer that works with non-iOS peers).
The following errors are produced:
Not allowed to load local resource: blob: blobinternal:///59c84caa-3e1c-4a00-91f4-c655a7ce638c
and
TypeError: Argument 1 ('stream') to RTCPeerConnection.addStream must be an instance of MediaStream

I have verified that the various required elements in config.xml, etc are correct.

Thanks for your help.

@phillx
Copy link

phillx commented Mar 21, 2018

Hello @cdcv , could you provide more informations ?

iOS Version,
XCodeVersion,
etc. ?

Actually i had hard times with webRTC at iOS and finally all working :)

@cdcv
Copy link
Author

cdcv commented Mar 21, 2018

Versions should be close to 'the latest of everything'.
XCode 9.1.
iOS 11.0.3.
Building with Cordova 7.1.0, iOS platform 4.5.4.
Thank you for your help.

@azachar
Copy link

azachar commented Mar 21, 2018

I have the same issue when I change a front camera to a back one.

@phillx
Copy link

phillx commented Mar 22, 2018

@cdcv @azachar ok cool, I gonna in next day max two prepare for you briefing of my solution, because I had same and it have been long process :)

@jbolthouse
Copy link

@phillx - Did you ever have a chance to prepare your briefing to this solution? I am really curious about how you got through it.

@rhammouda
Copy link

Same issue for me

@Barlocker-Garrett
Copy link

Barlocker-Garrett commented Apr 20, 2018

I have the same error, but I am only using audio Not allowed to load local resource: blob:blobinternal:///6386b5f2-39f6-4739-ae0d-457944a779fd

Side note: I know the WebRTC connection is working at least one way since I can hear this devices microphone being picked up and broadcast to an Android phone, but the media source from the Android is throwing this error.

XCode 9.3
iOS 11.3
Building with Cordova 7.1.0, iOS platform 4.5.4

@c3bola
Copy link

c3bola commented Apr 30, 2018

@phillx I have the same problem, I would like to know the solution

@jjahifi
Copy link

jjahifi commented May 8, 2018

This type of problems are not related to the plugin. It is an inherent feature of the Cordova platform iOS. iOS requires you to explicitly allow media sources.

Adding "media-src * blob" to the <meta ... > should be sufficient.

I would suggest you to close the issue because it is not related to the plugin.

@azachar
Copy link

azachar commented May 9, 2018 via email

@jbolthouse
Copy link

jbolthouse commented May 9, 2018 via email

@menelike

This comment was marked as off-topic.

@jjahifi
Copy link

jjahifi commented May 30, 2018

There are several issues related to this. One is the meta-definition. The second is the requirements of the newest iOS-versions.

I have been using a meta like

<meta http-equiv="Content-Security-Policy"
 	      content="media-src * blob:;
 		       default-src 'self' gap://ready file://* *; 
 		       style-src 'self' 'unsafe-inline'; 
 		       script-src 'self' 'unsafe-inline' 'unsafe-eval'; 
 		       connect-src * ws: wss: http: https: 'self'
 		       http://YOUR_SERVER https://YOUR_SERVER
 		       'unsafe-inline'
 		       'unsafe-eval'
 		       http://*/* https://*/* https://*:*">

Yes, I know, not very safe. Actually a real problem. I do not like this either. But it works for me.

In the latest versions of iOS the security requirements have been updated into a more strict version. Apparently you need a bunch of inline-statements for video to work. Test with Safari, if it does not work, then you app is not likely to work with this plugin.

In order to have a bit mode freedom with the recent constraints I am using a development machine with macOS Sierra and iOS-devices with a bit old version of iOS 11.

Do not update it you can survive without it.

In addition, I have to point out that the current webrtc support in Safari is not as good as one may assume. Hence this plugin is one of the best possibilities of getting a working solution. Especially in private networks.

@its-Aman
Copy link

its-Aman commented Jun 8, 2018

I got it working by following code

Put following code in your index.html

<meta http-equiv="Content-Security-Policy" content=" media-src * blob: ; script-src 'self' 'unsafe-inline' 'unsafe-eval'; connect-src * blob: http: https: 'self' 'unsafe-inline' 'unsafe-eval' http://*/* https://*/* https://*:* ">

And in your ts file, cast the stream as ObjectUrl by following code.

this.local.nativeElement.src = window.URL.createObjectURL(stream);

@azachar
Copy link

azachar commented Jun 8, 2018

Yes, of course, it will work when you turn off CSP. But this is not acceptable on any production ready app, it is super unsafe!

@jjahifi
Copy link

jjahifi commented Jun 8, 2018

@azachar is, of course, right.

I have found that on iOS it is not intuitively clear with permissions should be given in order to get things working. For that reason I have started to do things in a way that I allow enough things in order to get app working. After that I drop permissions one by one. If things stop working, give the permission back. But try to remove another permission. After a few iterations you will have only the required ones left.

Another issue is that the library in the plugin is a bit old. For some functionality the API is not up to date (you have to use deprecated functions). If I have time I will have a look at the possibility of updating the library.

@cah-kyle-dunn
Copy link
Contributor

@azachar The interesting part is that this library worked fine without any CSP specified on the iOS 10 SDK, but is now failing with the iOS 11 SDK. Seemingly, Apple added some new rules that require you to include some CSP, even if it's a relatively useless CSP.

@NicholasMendes
Copy link

Has anyone got it working even by using custom tag ? Im stuck with the following error.

Not allowed to load local resource: blob:blobinternal:///da926413-1b82-44e4-af61-5dd80c8fef5f

@syonip
Copy link

syonip commented Jan 31, 2019

what actually fixed it for me was changing video.srcObject = stream; to video.src = window.URL.createObjectURL(stream);
thanks to @its-Aman 's comment

@cah-kyle-dunn
Copy link
Contributor

Has anyone got it working even by using custom tag ? Im stuck with the following error.

Not allowed to load local resource: blob:blobinternal:///da926413-1b82-44e4-af61-5dd80c8fef5f

I think the Not allowed to load local resource blob:... errors are actually just red herrings. The issue I had was solved with #348. However I still see those errors even though everything is functioning correctly.

@syonip
Copy link

syonip commented Feb 3, 2019

@cah-dunn I tried to incorporate this change but it doesn't make the video show.
using window.URL.createObjectURL(stream); does show the video, although when scrolling the page it stays static, I guess that is a different issue.

@cah-kyle-dunn
Copy link
Contributor

@syonip if you're on the latest version (v4.0.2) the srcObject issue should be fixed (e.g. you shouldn't have to use createObjectURL) since #270.

You might need to call refreshVideos manually to update the positioning after a scroll.

@hthetiot
Copy link
Contributor

Yes if you have CSP meta or header you may need to add media-src * blob:.
Will add documentation in the future.

@hthetiot
Copy link
Contributor

hthetiot commented Aug 18, 2019

We can close this issue cause #270 fix the issue.
@cah-dunn I did regenerate cordova-plugin-iosrtc.js in v5.0.0 if you want to confirm the final fix.

d207c44#diff-2a6d07eef8b10b84129b42424ed99327

@hthetiot hthetiot added this to the 5.0.x milestone Aug 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests