Summary | Image Attachments via ActiveSync: Last Byte Missing? |
Queue | Synchronization |
Queue Version | FRAMEWORK_5_2 |
Type | Bug |
State | Resolved |
Priority | 1. Low |
Owners | mrubinsk (at) horde (dot) org |
Requester | guenter (at) vista-rasch (dot) com |
Created | 08/15/2015 (3655 days ago) |
Due | |
Updated | 08/22/2015 (3648 days ago) |
Assigned | 08/20/2015 (3650 days ago) |
Resolved | 08/20/2015 (3650 days ago) |
Github Issue Link | |
Github Pull Request | |
Milestone | |
Patch | No |
running CentOS 7.1, client Archos 45c Platinum running Android 4.4.2)
Excellent work! :)
Taken from Jan Schneider
State ⇒ Resolved
Taken from slusarz@horde.org
The mails with attachment load now really fast, like never before on
the smartphone.
Thank you for the workaround.
I've tested on all of my test VMs including 5.5.x and 5.6.x with and
without the Debian package and they all seem to work with the test
email that was broken earlier.
commit 97ad57bc3568286a14c41bc28d99f94bfce83d97
Author: Michael J Rubinsky <mrubinsk@horde.org>
Date: Wed Aug 19 22:52:00 2015 -0400
Bug: 14086Work around various broken PHP behaviours regardingstream filters.
It appears to be safe to use the base64-encode filter when it's attached
as a STREAM_FILTER_WRITE. The behavior is only broken when the stream is
being read through the filter, so perform the filtering in this method
instead of just attaching the filter to the stream that is passed to the
wbxml encoder. Adds a small memory overhead but this now works reliably
with packages such as Debian's that have removed the BC breaking PHP
patch as well as with PHP binaries that have the change included.
.../Message/AirSyncBaseFileAttachment.php | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
http://github.com/horde/horde/commit/97ad57bc3568286a14c41bc28d99f94bfce83d97
Assigned to slusarz@horde.org
Assigned to Jan Schneider
State ⇒ Feedback
This commit:
https://github.com/php/php-src/pull/936
which was an attempt to fix the base64-encode stream filter was BC
breaking against PHP 5.x. This discussion:
https://bugs.php.net/bug.php?id=68948
explains the issue in detail. In fact, I remember this discussion and
I'm surprised I didn't put 2 and 2 together for THIS bug report....
At this point, I'm really not sure what to do. Debian reverted the BC
breaking commit - which IMO is probably the best course of action.
However, this means that we are screwed either way, as in Debian we
have the original broken behavior of the base64 filter, but in pure
PHP we have completely broken stream handling in some pretty critical
places.
Adding Michael S. and Jan to this ticket, as they were the main
participants in the above mentioned ticket.
more traffic in the horde mailing list on this issue.
Open a Debian bug:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=796169
https://github.com/oerdnj/deb.sury.org/issues/103
https://bugs.php.net/bug.php?id=68532
currently installs php 5.6.12.
Not sure why the changelog for php says it's fixed in 5.6.5, unless it
is a regression. Either way, verified that the issue is with the
base64 stream filter as described below.
Can you try the fix, or something similar, to what I posted? If that
"fixes" it for you, it's definitely a PHP issue with the stream filter.
exhibited this behavior but my main dev box did not.
memoryStream = dGVz
fileStream = dGVzdA==
samuel@wds:~/php5$ dpkg -l | grep php
ii dh-php5 0.2 all
debhelper add-on to handle PHP PECL extensions
ii libapache2-mod-php5 5.6.9+dfsg-0+deb8u1 amd64
server-side, HTML-embedded scripting language (Apache 2 module)
ii php-pear 5.6.9+dfsg-0+deb8u1 all
PEAR - PHP Extension and Application Repository
ii php5 5.6.9+dfsg-0+deb8u1 all
server-side, HTML-embedded scripting language (metapackage)
ii php5-cgi 5.6.9+dfsg-0+deb8u1 amd64
server-side, HTML-embedded scripting language (CGI binary)
ii php5-cli 5.6.9+dfsg-0+deb8u1 amd64
command-line interpreter for the php5 scripting language
ii php5-common 5.6.9+dfsg-0+deb8u1 amd64
Common files for packages built from the php5 source
ii php5-dev 5.6.9+dfsg-0+deb8u1 amd64
Files for PHP5 module development
ii php5-gd 5.6.9+dfsg-0+deb8u1 amd64
GD module for php5
ii php5-imagick 3.2.0~rc1-1 amd64
Provides a wrapper to the ImageMagick library
ii php5-imap 5.6.9+dfsg-0+deb8u1 amd64
IMAP module for php5
ii php5-json 1.3.6-1 amd64
JSON module for php5
ii php5-mcrypt 5.6.9+dfsg-0+deb8u1 amd64
MCrypt module for php5
ii php5-mysql 5.6.9+dfsg-0+deb8u1 amd64
MySQL module for php5
ii php5-readline 5.6.9+dfsg-0+deb8u1 amd64
Readline module for php5
ii pkg-php-tools 1.28 all
various packaging tools and scripts for PHP packages
samuel@wds:~/php5$
that do not have the fix in place (e.g. by checking the php version
number) be worth considering?
option like that down the call stack, only to work around a bug that
isn't our doing, and is already fixed.
about our results as soon as we have them.
that comes with <insert some distro here>" comments that always come
after a bug like this, I should say we won't work around this in
code since it would require holding the entire attachment in memory,
thus negating just about all of the work we do to minimize memory
usage by using streams. This could also very well hit your local php
memory limit.
do not have the fix in place (e.g. by checking the php version number)
be worth considering?
that comes with <insert some distro here>" comments that always come
after a bug like this, I should say we won't work around this in code
since it would require holding the entire attachment in memory, thus
negating just about all of the work we do to minimize memory usage by
using streams. This could also very well hit your local php memory
limit.
HOWEVER, if someone wants to work around this locally on their own
install knowing the consequences of doing so, what you need to do is
modify
Horde_ActiveSync_Message_AirSyncBaseFileAttachment::_checkEncoding()
method to pull the stream contents into memory, perform a
base64_encode() on them, and then write it back out to another stream
to return: So replace the inner block in that method with something
like this:
if (is_resource($data)) {
rewind($data);
$temp_data = stream_get_contents($data);
$data = fopen('php://temp/', 'r+');
fwrite($data, base64_encode($temp_data));
} else {
$data = base64_encode($data);
}
State ⇒ Not A Bug
https://bugs.php.net/bug.php?id=68532
Was fixed in 5.5.21 and 5.6.5, which explains why my test apache vm
exhibited this behavior but my main dev box did not.
ticket #12486based server. I can reproduce this when using Apache, but not on
lighttpd. It's definitely not a header or a chunked content issue
though.
At least I can reproduce this now.
ticket #12486and attach an activesync log contianing at least the ITEMOPERATIONS
command that fetches the attachment?
<ItemOperations:Range>
0-58830
</ItemOperations:Range>
<ItemOperations:Total>
58831
</ItemOperations:Total>
[...]
2015-08-18T22:25:02+00:00 INFO: [ANDROIDXXXXXXXXX] Handling
ITEMOPERATIONS command.
2015-08-18T22:25:02+00:00 DEBUG: [32523] I <ItemOperations:ItemOperations>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I <ItemOperations:Fetch>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I <ItemOperations:Store>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I Mailbox
2015-08-18T22:25:02+00:00 DEBUG: [32523] I </ItemOperations:Store>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I <AirSyncBase:FileReference>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I INBOX:3:2
2015-08-18T22:25:02+00:00 DEBUG: [32523] I </AirSyncBase:FileReference>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I </ItemOperations:Fetch>
2015-08-18T22:25:02+00:00 DEBUG: [32523] I </ItemOperations:ItemOperations>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:ItemOperations>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Status>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O 1
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Status>
2015-08-18T22:25:02+00:00 INFO: [32523] Creating new
Horde_ActiveSync_SyncCache.
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Response>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Fetch>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Status>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O 1
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Status>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <AirSyncBase:FileReference>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O INBOX:3:2
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </AirSyncBase:FileReference>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Properties>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Range>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O 0-58830
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Range>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Total>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O 58831
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Total>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <AirSyncBase:ContentType>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O image/png
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </AirSyncBase:ContentType>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O <ItemOperations:Data>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O [STREAM]
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Data>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Properties>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Fetch>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:Response>
2015-08-18T22:25:02+00:00 DEBUG: [32523] O </ItemOperations:ItemOperations>
2015-08-18T22:25:02+00:00 INFO: [32523] Maximum memory usage for
ActiveSync request: 18087936 bytes.
[...]
State ⇒ Feedback
on multiple android devices.
Can you send me an email containing an image that this occurs with and
attach an activesync log contianing at least the ITEMOPERATIONS
command that fetches the attachment?
Sent Mail Folder (IMP):
md5sum attachment: aa2d147b50c6eadb92d498942fb47cb8
size: 64750
Inbox Folder (IMP second server):
md5sum attachment: aa2d147b50c6eadb92d498942fb47cb8
size: 64750
Inbox Folder (Android):
Android can not open the attachment, but I can save it to the
downloads folder,
connect the smartphone to my pc and copy the image:
md5sum attachment: 5cce577cb27835a7b80d381d06c914d3
size: 64749
New Attachment: Screenshot_2015-08-18-12-54-3311111.png
will not display image (image loading error)
Priority ⇒ 1. Low
Priority ⇒ 2. Medium
State ⇒ Unconfirmed
Patch ⇒ No
Milestone ⇒
Summary ⇒ Image Attachments via ActiveSync: Last Byte Missing?
Type ⇒ Bug
Queue ⇒ Synchronization
display image attachments in EMails I discovered that apparently the
last byte is (sometimes/often) missing from those attachments,
verified by this experiment:
(1) send email to my horde account with image attached
(2) view email on android client connected via ActiveSync - client
will not display image (image loading error)
(3) save image attachment on android client to downloads folder on the device
(4) send email back with saved image attached to it
(5) compare size of original and received image:
-rw-r----- 1 guenter guenter 659625 Aug 14 22:33 speech_and_language (1).jpg
-rw-r----- 1 guenter guenter 659626 Aug 8 12:19 speech_and_language.jpg
effect is reproducible accross multiple devices and two separate horde
installations (one freshly installed, one in production use for
years). I am happy to provide further details (version numbers,
avticesync log) if that seems useful, just drop me a line.