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

my image screenshot in ios webview is occasionally white, #1995

Closed
boboZh opened this issue Sep 6, 2019 · 11 comments · Fixed by #2577
Closed

my image screenshot in ios webview is occasionally white, #1995

boboZh opened this issue Sep 6, 2019 · 11 comments · Fixed by #2577

Comments

@boboZh
Copy link

boboZh commented Sep 6, 2019

Bug reports:

my image screenshot in ios webview is occasionally white,
it acts like this "https://img4.easypass.cn/das/carsource1/origin/cac62901-8930-47e3-ac1d-cca42b9e64cc.png",
when add a border to the image, it acts like this, "https://img4.easypass.cn/das/carsource1/origin/d6ea23c2-5f88-44ed-ac74-d2b3c6a73dbd.png"

and here is my code:
Html2Canvas(poster, {
dpi: window.devicePixelRatio * 2,
useCORS: true, // 允许跨域图片
logging: false,
width: width,
height: height,
scale: scale,
canvas: canvas
})
.then(function (canvas) {
let imgBlob = canvas.toDataURL('image/jpg', 1.0)
that._uploadImg(imgBlob)
let shareBase64 = imgBlob.match('data:image/png;base64,') && imgBlob.split('data:image/png;base64,')[1]
that.base64Url = shareBase64
that.$refs.shareWrapper.show(that.shareTextOrigin)

      })
      .catch(err => {
        showToast(this, err.message)
      })

thank you

Specifications:

  • html2canvas version tested with: "^1.0.0-rc.3"
  • Browser & version: ios webview
  • Operating system: ios
@icksky
Copy link

icksky commented Sep 10, 2019

the same. try to transform the source image's src to base64, then use html2canvas to generate your image.
I debug the html2canvas, and found out that the image's complete is false, but never dispatch load event. So the intrinsicWidth and intrinsicHeight is 0 when new ImageElementContainer.
I don't know if this cause the bug. Hope a little help.

@boboZh
Copy link
Author

boboZh commented Sep 10, 2019

the same. try to transform the source image's src to base64, then use html2canvas to generate your image.
I debug the html2canvas, and found out that the image's complete is false, but never dispatch load event. So the intrinsicWidth and intrinsicHeight is 0 when new ImageElementContainer.
I don't know if this cause the bug. Hope a little help.

awsome! it works! thanks a lot!

@Viin-zx
Copy link

Viin-zx commented Sep 11, 2019

兄台,请问下如何处理的在ios手机下渲染白屏问题。有点没理解。

@boboZh
Copy link
Author

boboZh commented Sep 11, 2019

兄台,请问下如何处理的在ios手机下渲染白屏问题。有点没理解。

我的问题是渲染没毛病,但是截图有毛病,上面这位sky网友的意思是你把图片地址转为base64再放上去,试一下看行不行,我的OK

@Viin-zx
Copy link

Viin-zx commented Sep 11, 2019

@boboZh 哥,请教下您知道为什么在ios上渲染不出来dom中的图片么,概率性事件,概率还挺大的。web和安卓都没问题。找了几天都没找到解决方法。

@boboZh
Copy link
Author

boboZh commented Sep 11, 2019

@boboZh 哥,请教下您知道为什么在ios上渲染不出来dom中的图片么,概率性事件,概率还挺大的。web和安卓都没问题。找了几天都没找到解决方法。

这个不清楚诶,没有遇到过

@the-natty
Copy link

@boboZh 哥,请教下您知道为什么在ios上渲染不出来dom中的图片么,概率性事件,概率还挺大的。web和安卓都没问题。找了几天都没找到解决方法。

the same problem!

@boboZh
Copy link
Author

boboZh commented Oct 9, 2019

the same. try to transform the source image's src to base64, then use html2canvas to generate your image.
I debug the html2canvas, and found out that the image's complete is false, but never dispatch load event. So the intrinsicWidth and intrinsicHeight is 0 when new ImageElementContainer.
I don't know if this cause the bug. Hope a little help.

but now, it can reproduce occassionally with base64 src, do you know how to do with this?

@icksky
Copy link

icksky commented Oct 10, 2019

but now, it can reproduce occassionally with base64 src, do you know how to do with this?

I also found out this, but sorry, I have no idea too.

@mliotinoca
Copy link

mliotinoca commented Apr 9, 2021

Increasing imageTimeout value don't solve it completely.
Issue happens randomly anyway, I think on heavy images, even in base64.
I have solved by this #2344

@wenlittleoil
Copy link

wenlittleoil commented Apr 25, 2023

2023, the problem still exist in some iphone.

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

Successfully merging a pull request may close this issue.

6 participants