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

generate image no response in IOS 15.4 #2864

Open
UntilGone opened this issue Mar 24, 2022 · 20 comments
Open

generate image no response in IOS 15.4 #2864

UntilGone opened this issue Mar 24, 2022 · 20 comments

Comments

@UntilGone
Copy link

UntilGone commented Mar 24, 2022

Bug reports:

Generated image no response when updated IOS to 15.4. Without error or log. Same code in IOS 15.3 running ok.

Demo

/* the dom */
<div>1111</div>
import html2canvas from 'html2canvas';
html2canvas(dom, {
      width: dom.clientWidth,
      height: dom.clientHeight,
      useCORS: true,
      scale: window.devicePixelRatio,
    })
      .then((canvas) => {
        console.log('test111');
        if (canvas) {
          resolve(canvas.toDataURL());
        } else {
          reject(new Error('something wrong'));
        }
      })
      .catch((err) => {
        console.log('test4');
      })
      .finally(() => {
        console.log('test5');
      });
// this code has no log

Specifications:

  • html2canvas version tested with: 1.4.1
  • Browser & version: Safari
  • Operating system: IOS 15.4
@vendra95
Copy link

I have the same problem after update IOS 15.4 on Safari and Chrome browser

@ZhangHang12135
Copy link

+1

@j4n17
Copy link

j4n17 commented Apr 1, 2022

same problem

@Vstar18
Copy link

Vstar18 commented Apr 15, 2022

same

@TuffyLiu
Copy link

same problem

@osnysantos
Copy link

Same problem

@niniks
Copy link

niniks commented Apr 25, 2022

same

@zhe-he
Copy link

zhe-he commented Apr 27, 2022

Modify scale: Math.min(window.devicePixelRatio, 2)
Can solve this problem.

@konradsajdak
Copy link

konradsajdak commented Apr 27, 2022

I found issue with iframeLoader in DocumentCloner. In Safari 15.4 and newest MacOS do not call onload function on iframe, created by script and his readyState is interactive all the time so, condition in setInterval is never truthly.

Temporary soluction is remove onload function, use exist setInterval and modify condition with be checking readyState.

var interval = setInterval(function () {
    if (documentClone.body.childNodes.length > 0 && (documentClone.readyState === 'complete' || documentClone.readyState === 'interactive')) {
        clearInterval(interval);
        resolve(iframe);
    }
}, 50);

Code to replace:

cloneWindow.onload = iframe.onload = () => {
cloneWindow.onload = iframe.onload = null;
const interval = setInterval(() => {
if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
clearInterval(interval);
resolve(iframe);
}
}, 50);
};

@jesben
Copy link

jesben commented May 9, 2022

version 1.3.4 works in iOS 15.4.x, but version 1.4.1 do not, either it does not return or it is 10 times slower, no errors! using html2canvas with jsPDF...

@aelbore
Copy link

aelbore commented May 30, 2022

I found issue with iframeLoader in DocumentCloner. In Safari 15.4 and newest MacOS do not call onload function on iframe, created by script and his readyState is interactive all the time so, condition in setInterval are never truthly.

Temporary soluction is remove onload function, use exist setInterval and modify condition with be checking readyState.

var interval = setInterval(function () {
    if (documentClone.body.childNodes.length > 0 && (documentClone.readyState === 'complete' || documentClone.readyState === 'interactive')) {
        clearInterval(interval);
        resolve(iframe);
    }
}, 50);

Code to replace:

cloneWindow.onload = iframe.onload = () => {
cloneWindow.onload = iframe.onload = null;
const interval = setInterval(() => {
if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
clearInterval(interval);
resolve(iframe);
}
}, 50);
};

so far this works for me thanks @konradsajdak

@toffifeeIt
Copy link

toffifeeIt commented May 31, 2022

I had an issue generating image on IOS 15.4.1 and once I removed a background-image and replaced it with an <img> it was resolved.

@mattyforth
Copy link

Same problem with Safari browser on Mac

@niniks
Copy link

niniks commented Jun 28, 2022

Since i couldnt get the problem gone i switched to the package > html-to-image
Sofar this is running great without problems, i hope this helps more people looking for a quick fix

@ryanatearth
Copy link

@niniks Is there an easy way to grab a main javascript file for this? Or is the only way to use node/npm, as I am not using either in my project?

@5PK
Copy link

5PK commented Jun 29, 2022

Modify scale: Math.min(window.devicePixelRatio, 2) Can solve this problem.

This worked for me. Happens when I pass a node thats very long.

@wyysf123
Copy link

The problem lies in the picture. I set loading='lazy' and the iframe does not trigger onload. Just delete loading='lazy'.

@shooooori0128
Copy link

shooooori0128 commented Mar 31, 2023

If you're using Next/Image, it sets loading="lazy" by default, so it change to loading="eager", then this problem will avoid.

@dangngocbinh
Copy link

I found issue with iframeLoader in DocumentCloner. In Safari 15.4 and newest MacOS do not call onload function on iframe, created by script and his readyState is interactive all the time so, condition in setInterval is never truthly.

Temporary soluction is remove onload function, use exist setInterval and modify condition with be checking readyState.

var interval = setInterval(function () {
    if (documentClone.body.childNodes.length > 0 && (documentClone.readyState === 'complete' || documentClone.readyState === 'interactive')) {
        clearInterval(interval);
        resolve(iframe);
    }
}, 50);

Code to replace:

cloneWindow.onload = iframe.onload = () => {
cloneWindow.onload = iframe.onload = null;
const interval = setInterval(() => {
if (documentClone.body.childNodes.length > 0 && documentClone.readyState === 'complete') {
clearInterval(interval);
resolve(iframe);
}
}, 50);
};

thank you so much @aelbore . It's worked!

@Mtaylorr
Copy link

Mtaylorr commented Jan 5, 2024

Hello , is there a version that solves this problem or not yet ?

Mtaylorr added a commit to odoo-dev/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

closes #148329

Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

X-original-commit: f11723f
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

X-original-commit: f11723f
fw-bot pushed a commit to odoo-dev/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

X-original-commit: f11723f
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

closes #149903

X-original-commit: f11723f
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 18, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

closes #149928

X-original-commit: f11723f
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
robodoo pushed a commit to odoo/odoo that referenced this issue Jan 19, 2024
Issue:
=====
Users with IOS can't sign with safari.

Steps to reproduce the issue:
=============================
- Install sign
- Make sure you have a template which has at least one signature sign
  item.
- Share the document and open the link with ios on safari in v 15.4+
  (browserstack) for example.
- Go to the signature sign item and use auto and click sign or sign all
- Nothing will happen.

Origin of the issue:
====================
niklasvh/html2canvas#2864

Solution:
=========
niklasvh/html2canvas#2864 (comment)

opw-3660682

closes #149914

X-original-commit: f11723f
Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
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