Problems with composeView.attachFiles(files) for big files

236 views
Skip to first unread message

Mykhailo O

unread,
Jul 13, 2016, 2:51:51 AM7/13/16
to InboxSDK
Hello!

I'm trying to attach file(s) with composeView.attachFiles(files) or with composeView.attachInlineFiles(files). (files = an array of Blob)

Everything was ok when it was a small file or a bunch of small files.

But when I try to attach a bigger file (f.e 15Mb) problems appear.

Gmail page freezes (do not respond) and nothing happens 10 - 60 seconds. After the file starts uploading with progress indication.

Do you have any idea how to avoid this problem?


Thank you!


Aleem Mawani

unread,
Jul 13, 2016, 3:13:19 AM7/13/16
to Mykhailo O, InboxSDK
Great question - we'll take a look at the performance of that function. In the meantime, can you tell us a little about your use case, we want to make sure there isn't a better way (like using the Gmail API) to accomplish what you're trying to do.

--
You received this message because you are subscribed to the Google Groups "InboxSDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inboxsdk+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inboxsdk/0b70ba0c-6b4a-4348-8a1a-c40effd5f5f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mykhailo O

unread,
Jul 13, 2016, 3:51:46 AM7/13/16
to InboxSDK, 332...@gmail.com
I'm working on FileCloud for Gmail Chrome extension.

In general, it is similar to Dropbox for Gmail but with an ability to attach file(s). Not only link(s).

So, I'm downloading file(s) in background script (with checking size etc), send to contentScript and attach to the letter with composeView.attachFiles.

середа, 13 липня 2016 р. 10:13:19 UTC+3 користувач Aleem Mawani написав:

Aleem Mawani

unread,
Jul 13, 2016, 4:01:14 AM7/13/16
to Mykhailo O, InboxSDK
Where are the files being downloaded from?

Mykhailo O

unread,
Jul 13, 2016, 4:05:11 AM7/13/16
to InboxSDK, 332...@gmail.com
From FileCloud  in background script (as Blob). 



середа, 13 липня 2016 р. 11:01:14 UTC+3 користувач Aleem Mawani написав:

Chris Cowan

unread,
Jul 13, 2016, 4:32:35 PM7/13/16
to InboxSDK
Thanks for reporting this issue! It has been fixed now.

We needed to simulate drag-and-drop events from the page's world rather than the content script's isolated world. We do this by injecting some javascript into the page's world and then communicating with it through events. When communicating a File object to the page world, we would convert it to an array of integers, attach that to the event, and then deserialize it into a new File object in the page world. This was slow for large files. Turns out we could just send File objects directly; I think older Chrome and Safari versions had issues with this which was why we didn't do this. We've removed the array serialization step now.

Aleem Mawani

unread,
Jul 13, 2016, 4:39:22 PM7/13/16
to Chris Cowan, InboxSDK
Also, if you're just downloading the file from your server to be attached, you could consider creating a draft in the users account directly using the Gmail API. That way the users computer doesn't need to download and upload the file.

--
You received this message because you are subscribed to the Google Groups "InboxSDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to inboxsdk+u...@googlegroups.com.

Mykhailo O

unread,
Jul 14, 2016, 5:10:50 AM7/14/16
to InboxSDK
Thank you! It works like a charm now. No freezes etc.

About serialization: I'm using blobToBase64String algorithm from this lib https://github.com/nolanlawson/blob-util (To send Blob from background page to the content script). It works fast for me.

----------------------------------------------------------------------------------------------------------------------------

Other point: 

I have noticed other issue with composeView.attachFiles.

It appears only when you are trying to attach file(s) if a draft is in fullscreen mode.

I see an error: Uncaught (in promise) Error: Failed to find dropzone in the console.

See screenshot:



Do you have an idea how to fix it?

середа, 13 липня 2016 р. 23:32:35 UTC+3 користувач Chris Cowan написав:

Mykhailo O

unread,
Jul 14, 2016, 5:15:15 AM7/14/16
to InboxSDK, co...@streak.com
Thank you for suggestion

In fact, I do not have a direct link to the file. To get a file from FileCloud I should make an Authorized API call to the Filecloud API. So I can't directly use Gmail API to attach a file.
User computer (Extension) should download it in any way.

середа, 13 липня 2016 р. 23:39:22 UTC+3 користувач Aleem Mawani написав:

Chris Cowan

unread,
Jul 14, 2016, 4:49:07 PM7/14/16
to InboxSDK


On Thursday, July 14, 2016 at 2:10:50 AM UTC-7, Mykhailo O wrote:
Thank you! It works like a charm now. No freezes etc.

About serialization: I'm using blobToBase64String algorithm from this lib https://github.com/nolanlawson/blob-util (To send Blob from background page to the content script). It works fast for me.

You might be able to remove any delay at all by sending the File/Blob object directly if Chrome supports that when talking to the background page. 'chrome.runtime.sendMessage' might not support that, but I imagine the postMessage method of the port returned by 'chrome.runtime.connect' would. Reserializing the File/Blob is a performance cost proportional to the file size that might not be necessary at all.
 
----------------------------------------------------------------------------------------------------------------------------

Other point: 

I have noticed other issue with composeView.attachFiles.

It appears only when you are trying to attach file(s) if a draft is in fullscreen mode.

I see an error: Uncaught (in promise) Error: Failed to find dropzone in the console.

See screenshot:



Do you have an idea how to fix it?

This was a pretty nasty bug! When this error happened, we would leave Gmail's dropzone elements hidden in the page but blocking clicks. We've fixed it to handle failures more gracefully, and then we fixed the root cause so that it works correctly. 

Mykhailo O

unread,
Jul 15, 2016, 3:02:45 AM7/15/16
to InboxSDK
Thank you for the answer.

I have tried the Port communication. With `chrome.tabs.connect` and `chrome.runtime.onConnect` to send a Blob to a content script. It does not work. 
Of course, Message communication does not work too.
That why I'm using Blob to base64.
I can't find a better solution at the moment.

Thank you for a bugfix. It works perfectly now!


четвер, 14 липня 2016 р. 23:49:07 UTC+3 користувач Chris Cowan написав:
Reply all
Reply to author
Forward
0 new messages