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

Canvas video stream freezes on mobile safari #14

Closed
pkpp1233 opened this issue May 31, 2018 · 12 comments
Closed

Canvas video stream freezes on mobile safari #14

pkpp1233 opened this issue May 31, 2018 · 12 comments

Comments

@pkpp1233
Copy link

pkpp1233 commented May 31, 2018

Describe the bug
iPhone 7 and 8 for mobile safari face tracking seems to be broken.

Specifically, if you look at the 2d face paint demo, the canvas loads, shows the first few images, then freezes. Console shows the following error: WebGL: INVALID_OPERATION: texImage2D: type HALF_FLOAT_OES but ArrayBufferView is not NULL

To Reproduce
Steps to reproduce the behavior:

  1. You can reproduce using an iPhone on iOS 11, mobile safari.
  2. Open https://jeeliz.com/demos/faceFilter/demos/canvas2D/faceDraw/
  3. Your picture will load, but video stream will freeze. You'll still be able to draw.

Expected behavior
I'd except the video stream / canvas to not freeze while tracking face. It works properly on desktop and android mobile.

Screenshots
n/a

Smartphone (please complete the following information):

  • Device: iPhone7
  • OS: iOS11
  • Browser safari
@xavierjs
Copy link
Member

xavierjs commented Jun 1, 2018

Thank you for this detailed bug report. Fortunately I can reproduce it on my ipad pro, it freezes perfectly well ! I will fix it today.

@pkpp1233
Copy link
Author

pkpp1233 commented Jun 2, 2018

Awesome 👍, thanks @xavierjs.

@pkpp1233
Copy link
Author

pkpp1233 commented Jun 3, 2018

If helpful, I did notice when I refreshed a few times, 1 out of every few ended up not freezing. Seems like a timing issue.

@xavierjs
Copy link
Member

xavierjs commented Jun 4, 2018

This bug was pretty hard... This is a problem with IOS.
Since a recent update I cannot use a

xavierjs added a commit that referenced this issue Jun 4, 2018
@xavierjs
Copy link
Member

xavierjs commented Jun 4, 2018

I have pushed the modif and it works for me with Ipad pro (I tried with Safari in private navigation to avoid any browser cache problem). I hope it will work for you too !

@pkpp1233
Copy link
Author

pkpp1233 commented Jun 4, 2018

Taking a look now. Will report.

@pkpp1233
Copy link
Author

pkpp1233 commented Jun 4, 2018

Works great! Thanks for the fix. 🚀

@ashique12009
Copy link

Actually i am trying it in tensorflow JS, in there i am facing same freezing issue.
Could you tell me how you solve it @xavierjs?

Thank you.

@xavierjs
Copy link
Member

xavierjs commented Mar 6, 2020

It may be due to the GPU. I had a similar issue with an old laptop, the GPU was overheating and it triggered thermal throttling.

I don’t use tensorslow and face filter does not rely on it, but I know that tensorflow.js uses WebGL too to run.

@namklabs
Copy link

namklabs commented Aug 27, 2020

@ashique12009 Greetings! I just fixed this issue in my app. In my app, all iOS devices had problems with freezing video or black screen video; I was using the video stream from the device's rear (environment) camera. The solution to the problem was to make sure the <video> element is appended to the DOM. The code I was using created a <video> element but did not add it to the DOM. I believe this is the cause of the problem. As @xavierjs mentioned above, it sounds like you have to use CSS to creatively hide the <video> element, as simply using display: none will bring the problem back. In my app's case, the <video> element appears underneath another element so I didn't have to worry about hiding it. Good luck!

@xavierjs
Copy link
Member

I have reopened the issue and pinned it since it seems to be still a real problem.
If you create your own <video> element and use MediaStream API by yourself, yes you have to do the trick mentioned by @namklabs

If you let the lib to request the video (like in the boilerplate and most of the included demos), then we will test if it is an apple device (Safari on IOS or desktop). If yes, we append the <video> element to the DOM and we apply this CSS style:

setTimeout(function(){
  video['style']['transform'] = 'scale(0.0001,0.0001)';
  video['style']['position'] = 'fixed';
  video['style']['bottom'] = '0px';
  video['style']['right'] = '0px';
  
  setTimeout(function () {
    video['play']();
  }, 100);

}, 80);

It is dirty but it seems to work...

@andrejustinnn
Copy link

add playsinline on video tag like this "" looks good to me, i notice that my video wasn't appearing n playing in any browsers on iphone. except, including playsinline on the tag. I believe this is the cause of the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants