Does your website use flash?

Source: Internet
Author: User
Keywords Upload we this time can

Two years ago, we developed a set of flash based files (mainly images) to upload RIA applications to users of Alibaba. If you have used WordPress or Flickr to upload images, you should have used similar products. This program is based on Yui uploader development, added a practical function--in the client first to shrink the picture, and then upload to the server. Users with digital camera photos often have more than 6 million pixels, but the product picture on the Alibaba website shows that do not need such a large pixel, usually reduced to 1024x1024 within the ratio. With the help of Flash to reduce the picture before uploading the technology, we did not increase the server input, the original upload picture size limit from 250kb/Zhang to 5mb/Zhang. At the same time, flash upload more than the traditional HTML form upload has a better experience, for example, you can select a number of files at the same time upload, you can display real-time upload progress, select files can filter non-picture files.

This component has been a great success. Soon after the online, the number of users posted on Alibaba's website rose from around 10,000 daily to about 150,000 daily. But in the two years that the app was uploaded, we ran into a variety of problems.

1. BUG

In the case of the fake sandbox in the IE multi-label browser, the problem of the cookie is the most serious. Using Filereference.upload to upload files, the cookie information that comes with the HTTP request is not necessarily a cookie for the current browser process, but is very serious in Firefox, Chrome and other non-IE browsers, It is possible to transmit cookies in IE. Even IE, the cookie content that may be transferred does not match the current page's cookie record. This directly causes the server side to fail in security verification after the file is received. And for Alibaba such a large web site, there is a more mature Java web framework, to remove the reliance on cookies is very cumbersome. So the result is, first of all, we only use the IE browser when using flash upload, and secondly, we regularly also receive the use of some of IE customer complaints, after spending a lot of time to troubleshoot, I found that the problem is due to cookies caused by upload failure. This bug has been around for many years, but as Flash moved from 9 to 10, many versions passed and the problem remained unresolved. We are not in a hurry for closed-source flash.

2. Performance

The 5MB size limit is very conservative relative to the number of pixels in today's digital camera. However, when more than 5M, in some low configuration of the computer, read the contents of the file will occur when the browser suspended animation phenomenon. Suspended animation can easily cause the browser to crash, so we took a conservative limit--5MB.

Another performance drain is when encoding bitmapdata into a JPEG file. Adobe provides Jpegencoder, but performance is a problem because it is array-implemented. Encoding a 2880x2880 picture takes about 15 seconds on a medium-configured computer.

I rewrote this class with a vector that shortened to about 3.5 seconds. Using alchemy, the time is further shortened to about 1.5 seconds. However, it is not safe enough, so the asynchronous vector is used to prolong the encoding time to ensure the stability of the program. (Evaluation here)

3. Picture quality

The best image reduction algorithm built into Flash (with Bitmapdata.draw and set the smoothing argument to true) creates jagged edges when shrinking the picture. So I rewrote the jacwright provided by the reduction algorithm, picture quality problem solving, but the price is the performance of some lower.

4. Security Restrictions

After Flash10.0, a security restriction is added--when Urlloader sends a POST request as a standard file upload, it needs to be triggered by user UI actions (mouse clicks or keystroke events). Because we have done the user's image processing, can no longer upload through the filereference, only through the urlloader. This security restriction requires that each time a Urlloader request for an uploaded file be launched, the user must click the mouse. If the user chooses 20 pictures, click the mouse 20 times. This is clearly unacceptable. So we dropped the standard file upload, using the normal post form. The cost is to lose track of upload progress, do not know the percentage of file upload, and the server side needs to be modified.

Change

Recently, we made a decision to develop a similar function of ActiveX control, instead of flash as the main image upload solution. The advantage of ActiveX is performance, the disadvantage is that it can only be used in the Windows+ie browser, but in fact our flash upload is currently only used in IE. is flash really suitable for websites like Alibaba? Closed source and performance is the biggest problem of Flash. But before the HTML5 is widely supported, flash and traditional Ajax is our main rich client application development technology, compared to ActiveX, Silverlight, JavaFX, gear and other technologies, Flash still has the installation rate advantage. We see Adobe's recent commitment to new feature development, which is commendable, but the underlying functionality is as important as the developer. Flash is still our important RIA technology at the moment, but it's hard to say HTML5 's full arrival that day.

Source: http://www.ued163.com/?p=1813

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.