Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

App Crash due to android.os.TransactionTooLargeException #19

Closed
tknight00 opened this issue Feb 9, 2023 · 4 comments
Closed

App Crash due to android.os.TransactionTooLargeException #19

tknight00 opened this issue Feb 9, 2023 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@tknight00
Copy link

tknight00 commented Feb 9, 2023

Android 12
Ionic 6
Capacitor 4

I'm taking a screenshot using Capacitor Screenshot, and attempting to email it via Capacitor Email Composer.

I'm using the following code

let openOptions: OpenOptions = {
	attachments: [{
			name: 'screenshot.png',
			path: this.dataurl.split(",")[1],
			type: 'base64',
		}],
	body: 'Screenshot attached',
	bcc: [],
	cc: [],
	isHtml: false,
	subject: 'Screenshot',
	to: [],
};
EmailComposer.open(openOptions);

Gmail opens and I see the attached screenshot, and everything appears to of populated correctly for roughly 1 second before the app crashes. I can still send the email as all the data is correctly inserted. I don't see any console log errors. Removing the attached image prevents the crash.

----- Below is the DEBUG log generated by Android Studio -----

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: *removed*, PID: 5935
    java.lang.RuntimeException: android.os.TransactionTooLargeException: data parcel size 710264 bytes
        at android.app.ActivityClient.activityStopped(ActivityClient.java:86)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:226)
        at android.os.Looper.loop(Looper.java:313)
        at android.app.ActivityThread.main(ActivityThread.java:8663)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135)
     Caused by: android.os.TransactionTooLargeException: data parcel size 710264 bytes
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:635)
        at android.app.IActivityClientController$Stub$Proxy.activityStopped(IActivityClientController.java:1358)
        at android.app.ActivityClient.activityStopped(ActivityClient.java:83)
        at android.app.servertransaction.PendingTransactionActions$StopInfo.run(PendingTransactionActions.java:143) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loopOnce(Looper.java:226) 
        at android.os.Looper.loop(Looper.java:313) 
        at android.app.ActivityThread.main(ActivityThread.java:8663) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:567) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 
I/Process: Sending signal. PID: 5935 SIG: 9
Disconnected from the target VM, address: 'localhost:53579', transport: 'socket'

The screenshot image is only 693kb. Shouldn't this be a try/catch that generates a console.log? Also, how do I discover the file size limit? If it exceeds the limit, why is it still correctly populated in gmail?

@Prishii
Copy link

Prishii commented Oct 24, 2023

Android 13
Capacitor 5
Ionic 5

Facing the same issue while trying to send the jpeg images. The gmail opens and is populated with data correctly but the application crashes. There is no exception/error thrown either.

But, when used an image of size 10KB it works! So this might be related to the size? Anyways, there is no size limit given in the documentation also.
(works for pdf)

@EinfachHans
Copy link
Owner

I would appreciate PR's for this. I currently only have the time to manage this plugin for my own usage and i don't use attachments. If anyone has enough native experience to debug and fix this, it would be highly appreciated 🙏🏼

@EinfachHans EinfachHans added bug Something isn't working help wanted Extra attention is needed labels Oct 26, 2023
@develmood
Copy link

We found out that this limitation exists within the Android OS. This exception is thrown in different scenarios, for example when you want to share data from a size of about 500kb between two apps .So no problem that can be solved with this plugin.

Read more: https://developer.android.com/reference/android/os/TransactionTooLargeException

To work around the problem, the data must be saved on the device beforehand. You can use https://capacitorjs.com/docs/apis/filesystem for this.
The stored file can then be transferred to the email client via the path with EmailComposer.

@EinfachHans
Copy link
Owner

@develmood thanks for your investigation! I will add a note in the readme docs. Thanks 😊

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants