Android React Native app crashes on getUserMedia WebRTC call - javascript

I have been debugging this for days now and no longer have many options, hence the long shot question - I'm using the ConnectyCube WebRTC video calling package for React Native. I have also tried using the react-native-webrtc package to stream video from my Android device.
When using both packages my app crashes without any logs or errors when I call the getUserMedia method. I have to build the app again to use it.
Here is a previous post of mine that describes earlier problems I was having - however if you download and build ConnectyCubes app from the above link, their app works - I can't figure out why mine doesn't.
So my question is, is is there anything I should be checking for relating to the getUserMedia call in React Native that might be stopping it working?
I'm using:
RN v0.59.9
gradle wrapper 5.4.1
classpath(“com.android.tools.build:gradle:3.4.1”)
buildToolsVersion = “28.0.3”
compileSdkVersion = 28
I have reached out to support but have no fix yet.
Strangely, I'm unable to log the session parameter at certain points in the function. Thanks in advance.
const getUserMedia = session => {
console.log(session); // logs here
return new Promise((resolve, reject) => {
console.log(session); // but not here
session.getUserMedia({
audio: true,
video: { facingMode: 'user' }
}, function (error, stream) {
console.log(error, stream) // or here
error ? reject(error) : resolve(stream);
});
});
}
Update
The issue with the function above might be that for some reason the crash happens before the console can print anything out.

This was fixed by deleting the gradle cache and running npm i as described here:
How to clear gradle cache?

Related

navigator.mediaDevices.getUserMedia API rejecting with error "NotReadableError: Concurrent mic process limit."

During an active media flow(voice) navigator.mediaDevices.getUserMedia works fine when connected to internal mic, as soon as I switch to Bluetooth device and rerun the same API to fetch the latest media stream, I get the error "NotReadableError: Concurrent mic process limit."
I browsed throw many forums, as suggested by many that this error generally occurs in Firefox, Mac OS when multi tabs are trying to access mic or/and camera.
I made sure that only single tab is opened in Firefox browser, still see the same error.
Any leads on this shall be appreciated.
Below is the code snippet
constraints = {
"audio": {"deviceId": deviceId },
"video": false
}
let temp;
navigator.mediaDevices.getUserMedia(constraints).then(function(stream){
temp = stream;
}).catch(function(err) {
console.log(err.name + ": " + err.message);
});
Return below error message
NotReadableError: Concurrent mic process limit.
NOTES: Works fine in Chrome and Edge
Browser : Firefox 70.0.1 (64-bit)
OS : MacOS Mojave
NotReadableError: Concurrent mic process limit.
This means you cannot open more than one microphone at a time, per process, in Firefox right now. This limitation is a known bug that Mozilla is working on fixing.
In practice, this means you cannot open more than one microphone from your site (same-origin tabs typically share the same process). Make sure to call track.stop() when you're done with a mic.
Comes up during device switching
Few sites actually need to use two mics at once. But sites still run into this bug when switching from one microphone to another, because they generally open the new microphone before closing the old one.
Workaround
Call track.stop() on your existing microphone track, before attempting to obtain a track from a different microphone.
This strategy is similar to mobile where only one camera can be opened at once. The best approach is a fallback strategy: only stop the old track if necessary (that way there's no impact on other browsers):
async function getUserMedia(constraints, oldTrack) {
try {
return await navigator.mediaDevices.getUserMedia(constraints);
} catch (e) {
if (e.name != "NotReadableError") throw e;
oldTrack.stop();
return await navigator.mediaDevices.getUserMedia(constraints);
}
}
Done all that, but still get the same mic as before
When switching devices, use deviceId: {exact: deviceId}. I.e.
const constraints = {
audio: {deviceId: {exact: deviceId}},
};
This tells the browser you want this specific device or failure, and avoids a recent regression in Firefox.
While fallbacks to other devices are normally good, they're not when the user is trying to pick a specific device.

How can I add a custom chrome extension to my Electron app?

I am facing some trouble adding chrome addons into my Electron BrowserWindow.
Before creating my window (and after the ready event has fired), I try to add a devtools extension that my browser needs to do screen sharing.
BrowserWindow.addDevToolsExtension('/home/USER/.config/chromium/Default/Extensions/dkjdkjlcilokfaigbckcipicchgoazeg/1.5_0');
I followed this Electron guide, and it worked for their example (adding the react develop tool). When I do the exact same thing with my own chrome extension I have this error:
[4735:1116/163422.268391:ERROR:CONSOLE(7701)] "Skipping extension with invalid URL: chrome-extension://extension-name", source: chrome-devtools://devtools/bundled/shell.js (7701)
I don't really get why the error specified is "invalid URL" since I'm doing the exact same thing / process with the react addon without a problem. I also have no idea what to do. Is it possible that my chrome addon is not Electron-compatible?
It looks like you're trying to add a regular Chrome extension instead of a Dev Tools extension.
The BrowserWindow.addExtension(path) method is for regular Chrome extensions:
BrowserWindow.addExtension(path)
path String
Adds Chrome extension located at path, and returns extension's name.
The method will also not return if the extension's manifest is missing or incomplete.
Note: This API cannot be called before the ready event of the app module is emitted.
- https://electronjs.org/docs/api/browser-window#browserwindowaddextensionpath
Conversely, the BrowserWindow.addDevToolsExtension(path) method is for Dev Tools extensions:
BrowserWindow.addDevToolsExtension(path)
path String
Adds DevTools extension located at path, and returns extension's name.
The extension will be remembered so you only need to call this API once, this API is not for programming use. If you try to add an extension that has already been loaded, this method will not return and instead log a warning to the console.
The method will also not return if the extension's manifest is missing or incomplete.
Note: This API cannot be called before the ready event of the app module is emitted.
- https://electronjs.org/docs/api/browser-window#browserwindowadddevtoolsextensionpath
Note that in both cases you need to wait for the ready event from the app module to be emitted:
const { BrowserWindow, app } = require('electron')
let mainWindow = null
function main() {
BrowserWindow.addExtension('/path/to/extension')
mainWindow = new BrowserWindow()
mainWindow.loadURL('https://google.com')
mainWindow.on('close', event => {
mainWindow = null
})
}
app.on('ready', main)
Support for Chromium extensions in Electron is actively being worked on at the moment. The support isn't complete yet, but the GitHub issue seems to have regular updates being posted.
Fingers crossed!
A current pull request is open for 'just enough extensions [api] to load a simple ... extension'
Electron 9 has much more support for extensions!
To load them, use session.loadExtension: https://github.com/electron/electron/blob/master/docs/api/extensions.md
const { app, BrowserWindow, session } = require('electron')
// ... in your createWindow function, which is called after app.whenReady
const mainWindow = new BrowserWindow({...})
const ext = await session.defaultSession.loadExtension('/path/to/unpacked/chrome-ext')
console.log('ext', ext)
// outputs config file
// {
// id: 'dcpdbjjnmhhlnlbibpeeiambicbbndim',
// name: 'Up! – Free Social Bot',
// path: '/Users/caffeinum/Development/GramUp/chrome-ext',
// url: 'chrome-extension://dcpdbjjnmhhlnlbibpeeiambicbbndim/',
// version: '1.7.0',
// manifest: { ... }
// }
Read more: https://github.com/electron/electron/blob/master/docs/api/extensions.md
Also, there's another project that helps you do that, also adds additional functionality: https://github.com/sentialx/electron-extensions
While there is a documented method to register a normal extension, in majority of cases it won't do much, as Electron supports only an accessibility subset of the chrome.* APIs (apparently only the stuff required by Spectron and Devtron) and as they've stated a while ago, they don't have any plans to support Chrome extension APIs at a full scale.

Error: Invalid Adapter :idb in pouchdb + ionic 3 with using chrome (Version 63.0)

I am using pouchDb +ionic 3. During creating pouchDb with ionic 3 without mention any parameter (by default: websql) it's working fine. But whenever I try to use adapter (indexedDB) like :
setupDB() {
this.db = new PouchDB('Contacts', {adapter : 'idb'});
}
it's thrown an error :
ERROR Error: Invalid Adapter: idb
at new PouchDB$5 (VM46 vendor.js:118540)
Please Help.
I think this is a known issue specifically for iOS mobile.
You can see this being discussed in this thread:
https://github.com/pouchdb/pouchdb/issues/6946
Seems like the fix is in flight:
https://github.com/pouchdb/pouchdb/issues/7085
So we should upgrade soon and this will hopefully resolve it.
UPDATE: ALSO make sure your iOS browser is NOT in incognito mode. Such modes do not allow persistence of data.

UWP App crash on phone lock while playing video

It is JavaScript based UWP application. Application is listening to checkpoint/resume event as described on MSDN samples. On checkpoint I'm saving state of the application like history.
How can I prevent application from crashing? What would be the exact sequence of events that occur when phone is locked.
on checkpoint:
app.oncheckpoint = function (args) {
try {
args.setPromise(Ax.Utils.delay(1000).then(function (r) {
WinJS.Application.sessionState.history = {}; //json string
return true;
}));
} catch (e) {
}
};
Debugging from Visual studio using Lifecycle state works well.
Wish to add answer to my own question.
Application was crashing due to google ads object included in the stream was not well formed that was causing the app to crash. Such as ads array was not handled correctly during checkpoint.

Trigger.io: : Unhandled intent result

I am using Trigger.io to develop an application.
After using file.getImage and selecting an image from either the gallery or camera (on Android) I get this error message (Using trigger.io toolkit to run the app).
W Forge : Unhandled intent result, should have been handled by Forge.
The app promptly crashes and restarts.
relevant code:
forge.file.getImage({}, function(file) {
forge.request.ajax({
type: 'POST',
url: "http://example.com/upload/photo",
files: [file],
success: function(e) {
console.log('success');
console.log(JSON.stringify(e));
},
error: function(e) {
console.log('failure');
console.log(JSON.stringify(e));
}
});
What does this error mean?
I'm seeing this issue on older devices too. Apparently it's a common issue on both Phonegap and Native android apps also. More can be seen on this thread:
PhoneGap camera restarts the application
The following plugin was developed for Phonegap which resolves the issue. I would be great if something like this could be developed for Trigger.io
http://code.google.com/p/foreground-camera-plugin/
This problem is caused by the camera taking up memory on older Android devices causing it to unceremoniously shut down some apps to free up more memory.
We're working on providing more elegant handling of this situation or at least better debug output to tell you what's going on. The problem in this case was occurring on an Android 2.3 device, and could be worked around by shutting down some open apps / processes.
Update: we released a new foreground camera module to address this issue in our v1.4.41. platform version:
http://current-docs.trigger.io/modules/camera.html#modules-camera

Categories

Resources