-
-
Notifications
You must be signed in to change notification settings - Fork 335
Open
Labels
Description
YOU MUST read first!
Please use Community Forum for general technical discussions and questions.
- I have used Google with the error message or bug in association with the library and Cordova words to make sure the issue I'm reporting is only related to iOSRTC.
- I have provided steps to reproduce (e.g. using sample app code https://github.com/cordova-rtc/cordova-plugin-iosrtc-sample or updated
extra/renderer-and-libwebrtc-tests.jsfile). - I have provided versions of third party library name, ios, Xcode and plugin version and adapter.js version if used.
Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed, removing this checkbox will result in automatic closed issue.
Versions affected
- Cordova version (e.g 7.1.0): 10.0.0
- Cordova iOS version (e.g 5.1.0): 6.2.0
- Plugin version (e.g 6.0.12): 6.0.20
- iOS version (e.g 10.2): 13
- Xcode version (e.g 11.1 - 11A1027): 12.4
Description
The following patch of CanvasRenderingContext2D.prototype.drawImage has made drawImage asynchronous. This presents a problem when you want to call getImageData immediately after drawImage. Using a setTimeout to call getImageData will kind of work, but it might be better if drawImage returned a promise after it has been patched?
Referenced comment
6.0.15 support CanvasRenderingContext2D.drawImage on VideoElement with iosrtc MediaStream
// Apply CanvasRenderingContext2D.drawImage monkey patch
var drawImage = CanvasRenderingContext2D.prototype.drawImage;
CanvasRenderingContext2D.prototype.drawImage = function (arg) {
var args = Array.prototype.slice.call(arguments);
var context = this;
if (arg instanceof HTMLVideoElement && arg.render) {
arg.render.save(function (data) {
var img = new window.Image();
img.addEventListener("load", function () {
args.splice(0, 1, img);
drawImage.apply(context, args);
});
img.setAttribute("src", "data:image/jpg;base64," + data);
});
} else {
return drawImage.apply(context, args);
}Originally posted by @hthetiot in #116 (comment)