cesarvr / pdf-generator

Cordova plugin to generate pdf in the client-side
MIT License
107 stars 61 forks source link

Not working on some android devices #36

Closed PavleO closed 6 years ago

PavleO commented 7 years ago

Hey, I have problem with this plugin on some Android devices. It works perfectly on Android 6.0 But on devices with 5.1 and 7.0 it just dies silently (it does not call success or error callback) Only info I have about this problem are these two logs from logcat: W/ResourceType: Failure getting entry for 0x01080af0 (t=7 e=2800) (error -75) W/cr_BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 17312

Does anyone have any idea what could cause this?

fairport commented 7 years ago

We have this issue also. It has been caused by an Android update Android System WebView update 4 days ago Wasted 8 hours trying to figure out what we'd done to cause this. A client found the cause last night & uninstalled the update. That fixed the issue. Hopefully Cesar will get this fixed asap.

PavleO commented 7 years ago

Thank you for info. I also wasted more then half a day before giving up and opening issue. It is good to know that it was not because I did something wrong.

cesarvr commented 7 years ago

Hi all,

I have tested using the following Cordova setup:

I updated the Android VM's with latest patches to get all new features. I'm using this project:

Tested features

Test Result

Conclusion

Please check that you have the same Cordova & Android plugin version to see this you just need to do this:

# cordova version 
cordova -v    # it should return 6.5.0

# Cordova Android Plugin 
cordova platform  

#  Installed platforms:
#  android 6.2.2
#  ios 4.3.1

If you update this we should be in the same ground and it should work, also you can try this project to see if problems persist there as well.

PD: If some candid soul want to help with an automatic CI that would be cool 👍 .

fairport commented 7 years ago

News from me... $ cordova -v 6.5.0 $ cordova platform Installed platforms: android 6.2.2 $ cordova plugin -l cordova-pdf-generator 1.5.2 "PDFGenerator" & 13 other plugins.

using "base64" as I am embedding images (in 1 of about 12 PDF layouts & immediately send to the email plugin)

The upgrade of android platform had no effect. My emulators all behaved the same as before the upgrade. But none of this has had this Android WebView release, =======o0O0o======= The main story is this however... My main client-tester has 2 androids. On both of them, the plugin fails (i.e. nothing happens on the UI) with the new Android System WebView installed & enabled.

As with pavleo, the code does not go into either the success or failure callbacks...

When he disables that Android System WebView upgrade, the plugin works perfectly.

i.e. No change from the previous round of testing (prior to upgrading android platform from 6.1.2 to 6.2.2)

sorry ! ... Roger

PS. Sorry what do you mean by "an automatic CI"

cesarvr commented 7 years ago

Hi, I was able to reproduce the error , I went to this page and download the Android Webkit Update and get the same error (the callback never return after sending the request to generate a pdf in base64 format), I solve this problem and publish the update version 1.5.3, hopes this work for you guys.

With CI a mean continuos integration for this project using a platform like circleci if somebody have the time here is the issue.

fairport commented 7 years ago

Fixed! Thanks Cesar.

jonneroelofs commented 7 years ago

Fixed here as well. Lifesaver! Thanks.

vmexia commented 7 years ago

Damn I'm losing my mind with this bug. I had this exact problem on my app, after a bunch of lost hours I found this post and voilà, getting the newer version solved it... for a short while atleast. I was able to get the success callback for the base64 twice, then it stopped working again... no more callback responses.

Update 1: After posting this I went to bite a snack, it took me like 10 minutes, and when I came back I was able to get some base64's, then it stopped working again.

cesarvr commented 7 years ago

@vmexia , have you try this demo, your case can be due to slow network connection ? are you doing static html ?

vmexia commented 7 years ago

@cesarvr How would a slow internet connection affect the plugin?

cesarvr commented 7 years ago

@vmexia if you are loading from a remote URL, the Webkit need to download the HTML (and associated resources) before rendering and then transforming to PDF. For example let said the page weight 30mb of assets in a 1G mobile connection, it will look like the callback never get called when in reality is in the stage of downloading and is taking a huge amount of time. If that the case I would suggest to cache heavy assets in the device.

Check the static example, it should generate the base64 very fast.

vmexia commented 7 years ago

@cesarvr Right, by your previous comment I thought you meant that the plugin would have a timeout or something in place. I forgot to mention that I made a slight change to the plugin, instead of the LoadData webview function I use the function LoadDataWithUrl. Do you think that this change could affect the overall behaviour of the entire plugin? If so, could you explain why?

cesarvr commented 7 years ago

I think for the last version 1.5.3 I'm using loadDataWithBaseURL that work better for the relative urls inside the HTML, if not relative URL is found it work like loadData. There is no timeout because latency issues can be solved with a progress bar or just caching.

PavleO commented 7 years ago

Thank you Cesar, works perfectly also for: cordova 7.0.1 ionic 3.4.0 tested on many devices with android from 5.1 to 7.1