-
Notifications
You must be signed in to change notification settings - Fork 62
fix(android): fix crashes and faulty preview on Chrome 86+ #125
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
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
@Override | ||
public void onWriteFailed(CharSequence error) { | ||
super.onWriteFailed(error); | ||
|
||
Log.d(TAG, "onWriteFailed: Failed!!! " + error.toString() ); | ||
LOG.e(LOG_TAG, "onWriteFailed: Failed: " + error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here lies the reason of the crash. The error might be null according to the JavaDocs: https://developer.android.com/reference/android/print/PrintDocumentAdapter.WriteResultCallback#onWriteFailed(java.lang.CharSequence)
mWrappedInstance.onFinish(); | ||
webView.destroy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures to destroy the webView instance after the user either printed or cancelled the share PDF intent.
acc5f50
to
3b78a66
Compare
LOG.e(LOG_TAG, "getAsBase64 Error in I/O: ", ex); | ||
cordovaCallback.error(IO_EXCEPTION); | ||
} finally { | ||
this.webView.destroy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ensures that in both the success and error case of the base64 request the webView is successfully destroyed again.
3b78a66
to
d927e2d
Compare
//.setMinMargins(PrintAttributes.Margins.NO_MARGINS).build(); | ||
|
||
|
||
PrintDocumentAdapter printAdapter = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before, a printerAdapater was always initialized, even when the target was share
which uses the printerManager. Therefore, this code block was moved to the if block.
This is achieved by always using a new WebView instance and by destorying the old one fix(android): correct file name for temp folder fix(android): remove unused config file fix(android): register only one printer adapter fix(android): do not crash if error code is null (which is valid) refactor(android): use Cordova's log helper style: reformat codebase
d927e2d
to
04c7491
Compare
This is achieved by always using a new WebView instance and by destorying the old one
fix(android): correct file name for temp folder
fix(android): remove unused config file
fix(android): register only one printer adapter
fix(android): do not crash if error code is null (which is valid)
refactor(android): use Cordova's log helper
style: reformat codebase
This fixes #124