cordova-plugin-printer
cordova-plugin-printer copied to clipboard
ios 14 print crash
App crashes when cancel button is clicked from Print in ios 14
void _WebThreadLock(), 0x1069ec420: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
@kirtipriya - Have you faced this too ? https://github.com/katzer/cordova-plugin-printer/issues/266
@kirtipriya - Have you faced this too ? #266
Hello Anuj , I have not faced #266 . But to fix my crash , i used html2pdf to convert the html to pdf in base 64 format , and then i passed this base 64 output to the printer plugin. Can you try this too?
Hi kirtipriya... Yep, just came across this issue too. The XCode debugger suggests that iOS 14 requires this to run in a background thread. Have included some relevant output below that may assist in resolving this... Hope it helps!
Plugin should use a background thread. Unable to simultaneously satisfy constraints. ( "<NSLayoutConstraint:0x600002973570 UIView:0x7fc44a730760.width == UILabel:0x7fc44a4330a0.width + 28 (active)>", "<NSLayoutConstraint:0x600002973520 H:[UIImageView:0x7fc44a72f460]-(3)-UILabel:0x7fc44a4330a0 (active)>", "<NSLayoutConstraint:0x6000029733e0 UIImageView:0x7fc44a72f460.width == 22 (active)>", "<NSLayoutConstraint:0x6000029732a0 H:|-(0)-UIImageView:0x7fc44a72f460 (active, names: '|':UIView:0x7fc44a730760 )>", "<NSLayoutConstraint:0x600002973250 UILabel:0x7fc44a4330a0.right == UIView:0x7fc44a730760.right (active)>" ) Will attempt to recover by breaking constraint <NSLayoutConstraint:0x600002973520 H:[UIImageView:0x7fc44a72f460]-(3)-UILabel:0x7fc44a4330a0 (active)> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful. 2020-10-18 18:54:29.562855+1100 void _WebThreadLock(), 0x101d6e100: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
@kirtipriya - Have you faced this too ? #266
Hello Anuj , I have not faced #266 . But to fix my crash , i used html2pdf to convert the html to pdf in base 64 format , and then i passed this base 64 output to the printer plugin. Can you try this too?
Possible to share your code using html2pdf?
@kirtipriya - Have you faced this too ? #266
Hello Anuj , I have not faced #266 . But to fix my crash , i used html2pdf to convert the html to pdf in base 64 format , and then i passed this base 64 output to the printer plugin. Can you try this too?
Possible to share your code using html2pdf?
cordova.plugins.pdf.htmlToPDF({ data: htmlContent, documentSize: "A4", landscape: "portrait", type: "base64", footer: footerContent }, (sucess) => { console.log('success: ', success); cordova.plugins.printer.print('base64://' + success); }, (error) => console.log('error:', error)); }); }
Hi base64 solution is not working for me, still getting the same crash : void _WebThreadLock(), 0x133db9500: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now... it is only occurring with ios 14. can anyone please assist with it. Thanks
Same for me. Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now.
Anybody who wants quick solution can install plugin from here. All working fine with WKWebview.
Used the base64 solution suggested by @kirtipriya - it works for me
Can anyone suggest the right solution for this problem, we are facing same issue. does upgrading to latest version would be of any help? current version in use => 0.7.3
I ended up changing to a different plugin (cordova-pdf-generator) - it may suit depending on your needs.
I ended up changing to a different plugin (cordova-pdf-generator) - it may suit depending on your needs.
Does it serve same purpose as this plugin.
It was able to do what we had been previously been using cordova-plugin-printer for - but you'll need to check the details (https://www.npmjs.com/package/cordova-pdf-generator) against you're own app's requirements.
Hi Guys, Can someone please let me know how do we use this block and basically which method to be called from inside of this block ?? I tried few things but see the same behaviour. Everyone else is saying that this block should fix the crash issue but somehow it does not change the behaviour yet. What I think is it is not the base64 or html content which is the issue, it is the way in which the UIKit is being called from the plugin code.
Which exact block of code do we need to call from this ?
dispatch_sync(dispatch_get_main_queue(), ^{
//Your code goes here
});
@kirtipriya can you please help ?