{"action":"created","issue":{"url":"https://api.github.com/repos/muaz-khan/RecordRTC/issues/324","repository_url":"https://api.github.com/repos/muaz-khan/RecordRTC","labels_url":"https://api.github.com/repos/muaz-khan/RecordRTC/issues/324/labels{/name}","comments_url":"https://api.github.com/repos/muaz-khan/RecordRTC/issues/324/comments","events_url":"https://api.github.com/repos/muaz-khan/RecordRTC/issues/324/events","html_url":"https://github.com/muaz-khan/RecordRTC/issues/324","id":259416120,"number":324,"title":"Audio record ios 11 no data","user":{"login":"iamrototo","id":32159195,"avatar_url":"https://avatars3.githubusercontent.com/u/32159195?v=4","gravatar_id":"","url":"https://api.github.com/users/iamrototo","html_url":"https://github.com/iamrototo","followers_url":"https://api.github.com/users/iamrototo/followers","following_url":"https://api.github.com/users/iamrototo/following{/other_user}","gists_url":"https://api.github.com/users/iamrototo/gists{/gist_id}","starred_url":"https://api.github.com/users/iamrototo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iamrototo/subscriptions","organizations_url":"https://api.github.com/users/iamrototo/orgs","repos_url":"https://api.github.com/users/iamrototo/repos","events_url":"https://api.github.com/users/iamrototo/events{/privacy}","received_events_url":"https://api.github.com/users/iamrototo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":59,"created_at":"2017-09-21T08:30:49Z","updated_at":"2018-03-15T19:58:31Z","closed_at":null,"author_association":"NONE","body":"Since iOS 11 and the support of getusermedia, I would like to use the record feature for safari on iPad but is not working at all.\r\n\r\nI checked this issue (https://github.com/muaz-khan/RecordRTC/issues/275). I have adapted my code to use StereoAudioRecorder. I get no error in the console but just that I record nothing (the data is 44 Bytes and is just empty) despite it works on chrome (PC). \r\n\r\nHere is my dumb test index. I try to record the voice of the user for 1 second and then I stop and get the data. To easily debug I push in the html the base64 and I have a quick audio html5 to be able to play the sound.\r\n\r\n\r\n```\r\n<!DOCTYPE html>\r\n<html>\r\n<head>\r\n<script src=\"https://webrtcexperiment-webrtc.netdna-ssl.com/RecordRTC.js\"></script>\r\n<script src=\"https://cdn.webrtc-experiment.com/gumadapter.js\"></script>\r\n</head>\r\n\r\n<body>\r\n<audio id=\"toto\" controls></audio>\r\n<div id=\"result\" style=\"max-width:500px;     word-wrap: break-word; \"></div>\r\n\r\n<script>\r\n\r\nfunction successCallback(audioStream) {\r\n    // RecordRTC usage goes here\r\n\t\r\n\tvar recordRTC = RecordRTC(audioStream, {recorderType: StereoAudioRecorder});\r\n\trecordRTC.startRecording();\r\n\t\r\n\tsetTimeout(\r\n\t\tfunction() {recordRTC.stopRecording(function(audioURL) {\r\n\t\t\tvar recordedBlob = recordRTC.getBlob();\r\n\t\t\trecordRTC.getDataURL(function(dataURL) { \r\n\t\t\t    var audio = document.querySelector('audio');\r\n                audio.src = dataURL;\r\n\t\t\t    document.getElementById(\"result\").innerHTML = dataURL;\r\n\t\t\t});\r\n\t\t});}, 1000);\r\n}\r\n\r\nfunction errorCallback(error) {\r\n    // maybe another application is using the device\r\n}\r\n\r\nvar mediaConstraints = { audio: true };\r\n\r\nnavigator.mediaDevices.getUserMedia(mediaConstraints).then(successCallback).catch(errorCallback);\r\n\r\n</script>\r\n</body>\r\n</html>\r\n```\r\n\r\nThanks for your help."},"comment":{"url":"https://api.github.com/repos/muaz-khan/RecordRTC/issues/comments/373503832","html_url":"https://github.com/muaz-khan/RecordRTC/issues/324#issuecomment-373503832","issue_url":"https://api.github.com/repos/muaz-khan/RecordRTC/issues/324","id":373503832,"user":{"login":"DrLongGhost","id":1702840,"avatar_url":"https://avatars2.githubusercontent.com/u/1702840?v=4","gravatar_id":"","url":"https://api.github.com/users/DrLongGhost","html_url":"https://github.com/DrLongGhost","followers_url":"https://api.github.com/users/DrLongGhost/followers","following_url":"https://api.github.com/users/DrLongGhost/following{/other_user}","gists_url":"https://api.github.com/users/DrLongGhost/gists{/gist_id}","starred_url":"https://api.github.com/users/DrLongGhost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DrLongGhost/subscriptions","organizations_url":"https://api.github.com/users/DrLongGhost/orgs","repos_url":"https://api.github.com/users/DrLongGhost/repos","events_url":"https://api.github.com/users/DrLongGhost/events{/privacy}","received_events_url":"https://api.github.com/users/DrLongGhost/received_events","type":"User","site_admin":false},"created_at":"2018-03-15T19:58:31Z","updated_at":"2018-03-15T19:58:31Z","author_association":"NONE","body":"I've made a lot of great progress this week, most notably I think I figured out what the main source of the instability in iOS is. Putting your phone into lock mode, opening another app that uses the microphone or backgrounding Safari all seem liable to breaking audio recording on a given tab in Safari **if the audio steam is left in place and not removed off the page.**\r\n\r\nAlmost all of the iOS issues I was seeing disappeared once I started using the following code to clean up in between my recordings:\r\n\r\n```\r\nstopRecording() {\r\n  this.processor.disconnect();\r\n  this.processor = null;\r\n\r\n  this.audioContext.close();\r\n  this.audioContext = null;\r\n\r\n// The conditional lets me safely call the function if we have an audioContext but no stream yet\r\n if (window._audioStream) {\r\n   window._audioStream.getTracks().forEach(track => track.stop());\r\n   window._audioStream = null;\r\n}\r\n```\r\n\r\nThe key here seems to be explicitly setting the context and stream to null. If I comment out the lines where I set these items to null, I immediately see recording problems return, whereas with this code in place, there are no issues remaining, afaict.\r\n\r\nI'm going to continue rambling on about some other stuff I'm doing and stuff I found in my testing, but I think my finding above was the big find (at least in my implementation). With my current code in place, I am only able to \"poison\" a tab if I open Voice Memos and record in there while Safari is also recording. Everything else, including sleeping the phone, no longer causes issues.\r\n\r\nDespite this, I actually came up with a great way to handle potential microphone problems. I was able to leverage @GersonRosales getVolume() function to keep track of all 0 volume 10ms segments. If you get only 0 volume for the first 3+ seconds of the recording, then you can safely assume the user has audio misconfigured (or in the case of an iPhone that the tab is poisoned). I then immediately show an error message with steps to fix it.\r\n\r\nFor iOS, the poisoned tabs can be fixed by one of two methods:\r\n1) Force-Quit Safari\r\n2) The user manually opens a new tab via the Plus button in Safari\r\n\r\nI find it intriguing that a manually opened new tab always gives you a working tab 100% of the time, but a new tab created via window.open() or `<a target=\"_blank\">` does not. I wish I understood why this was.\r\n\r\n@kaliatech / @GersonRosales -- I'm curious to see if you can replicate my findings. I now have a solid, working implementation that doesn't depend on either of the fixes (opening a second audio stream and keeping the audio stream open in between recordings) that @kaliatech put in place. I'm now using something very close to Gerson's Example 3 with my new bug fix to the StopRecording() method and some extra logic around error handling and other things."}}
{"actor":{"display_login":"DrLongGhost"}}