Saturday, February 27, 2016

Flash Player Trusted Files

Trust Me Flash Player

I was attempting to build the new Apache Flex JavaScript project and ran into a problem when attempting to run the unit tests. The tests run on a standalone version of Flash Player and were definitely attempting to run, but I was receiving a Security Error #2017 “Only trusted local files may cause the Flash Player to exit.” I could dismiss the error, but there were lots of tests and each test would pop up the same pop up. I vaguely knew that Flash Player has security limitations when it comes to running swf applications on the local file system, but since I usually run Flex unit tests via the FlexMojos maven plugin I had never seen this before.

Tough Search

I search and searched the internet and eventually found the answer to the problem buried in an Adobe help page . Hopefully my page will be a little easier to find.

The Solution

Just in case the Adobe page disappears I will also post the fix here. Flash Player allows you to configure a set of trusted directories for swf files, once you define them they will open without the Security Error.
  1. First you have to find the Flash Player #Security directory for your OS
    1. Windows Documents and Settings\username\Application Data\MacroMedia\Flash Player#Security
    2. Mac OS X /Users/username/Library/Preferences/Macromedia/Flash Player/#Security/
  2. Create a folder called FlashPlayerTrust inside the #Security folder.
  3. Create a new file in the FlashPlayerTrust directory using a text editor, and save it as myTrustFiles.cfg.
  4. You can use any unique name for your configuration file.
  5. Locate the directory where you test Flash applications.
  6. Type or paste each directory path (any directory path on your hard disk) on a new line in the file. You can paste multiple directory paths on separate lines. When you finish, your file looks similar to the following example: /Users/myuser/Development/source/swfs
  7. Save your changes to myTrustFiles.cfg

Sunday, February 21, 2016

Surface Book First Impression

I was over my brother’s house the other day and he plopped his shiny new Microsoft Surface Book down in front of me, pressed the power button and said, “Check this out.” I was very excited to see the hybrid tablet/laptop thing in person ever since the Apple podcast circuit started talking about the viability of living an iPad Pro only lifestyle. People have started taking sides and it has been interesting to see the many different perspectives on the situation. I am still not sure where I stand on the issue, because I split activities across iOS and Mac OS X. Using the Surface Book will give me a chance to see if I might just be better off with a single device that is both (well sort of) or if Apple’s stance on keeping iOS and Mac OS X separate is better.

Bad Start

Right away I was impressed by the screen on the Surface Book, probably because I have never had the pleasure of using a high resolution display on a PC or Mac for that matter. Windows seemed to be taking a really long time to load, so I asked my brother if this thing had an SSD or not. Eventually the Windows splash screen disappeared only to be followed by a Blue Screen of Death, which really looks nice on the display ;-) I held down the power button as I have often done on my work PC and gave Windows another try. It started right up this time and quickly loaded the login screen.

Keyboard Testing

The keyboard was attached so I immediately opened up a web browser and searched for my favorite typing speed test page. I opened up IE and did a search for typing test and just checked out one of the first results. The keyboard felt fine to me and I was able to type at about the same as normal. Most of the time I type on a Microsoft Ergonomic keyboard so any “regular” keyboard hurts my wrists after about a half an hour of typing.

Tablet Mode

I was most excited to try out the stylus and see how that felt on the Surface Book in tablet mode. Based on other reviews I knew there was some sort of software mechanism for detaching the screen so I asked my brother to show me how to do it. Sure enough down in the system tray is an icon for disconnecting the screen. The latch disengaged and I picked the tablet up, it didn’t seem any heavier than an iPad Pro to me. Once in tablet mode the top seemed to be slightly thinner than the bottom, which instinctually made me flip it over and to the lean forward to trigger the accelerometer to flip the display. Nothing happened. I tilted it forward again, because that is an old iOS trick when changing orientation. I shrugged it off and put it down on the table so it was slanted away from me. (Later on I fumbled throught the settings and found the orientation had been locked)

Full Windows in Tablet Mode

Once in tablet mode I had to find OneNote so I could do some drawing using the stylus. I tapped on the start menu and tapped until I found not one, but two OneNote applications. I tapped the first one and it asked me to log in with a Microsoft account, so I closed the window and opened the other one. In the process of navigating around it hit me that something didn’t feel right. I really didn’t like complex desktop type navigation on a tablet. I think the iPad’s giant sized iPhone home screen layout of apps could be improved (not sure how), but it is just so much more natural than drilling down into the Start Menu to look for an app. Yes I could have used search as I often do on my iPad, but this seemed clunky to me. I guess my brain has just been trained to expect a cleaner interface on a tablet device thanks to iOS. Either way it was an interesting moment for me.

The Stylus

Once I opened the correct OneNote I grabbed the stylus and started drawing. The lag when drawing wasn’t noticeable to me and the palm rejection was great. I drew some pictures and practiced zooming and rotating to see what things looked like. Overall it was a great experience. I handed the stylus over to my 9 year old son and he started drawing. He has used a stylus on my iPad Air for drawing before and was being very careful not to touch his palm to the screen. I told him how with this display he could put his hand down and it wouldn’t cause problems, which made him happy. He spent a few minutes drawing and intuitively changed colors, zoomed, panned and erased.

Final Thoughts

Despite the technical difficulties on start up, the SurfaceBook worked pretty well. The computer itself has a nice modern design and the keyboard was fine for me. Using the stylus was great and put to shame the stylus I currently use with my iPad Air. The process of detaching and attaching the tablet to the keyboard was kind of weird, but I guess since the GPU lives in the main body you probably don’t want to just pull it apart. My biggest take away from the whole experience was my dislike for the desktop interface when in tablet mode. It just didn’t feel right and seemed like way too much overhead for when you are just doing something as simple as tapping on the screen with your finger. The iPad home screen needs work, but in its current state beats using the Start menu every time. Of course I only used the tablet for about 15 minutes, so I am sure there are things that become natural over time, but I do use Windows almost 8 hours every day so its not totally foreign to me. I will consider to ponder the viability of the iPad lifestyle, but for now the only thing I know for sure is that keeping iOS and Mac OS X separate seems like a good long term bet, if only so the simple iOS interface doesn't become polluted with the sins of our desktop past.

Friday, February 19, 2016

Downgrade Flash Player in Google Chrome

Time to Downgrade

In a post earlier this week, Flash Problems, I talked about an issue I ran into with a recent Flash Player update that caused problems in the application I work on. After tracking down the problematic code I was able to fix it to get around the problem so going forward things should be fine. However, since it is an enterprise application that is installed and maintained by the user I can’t just push a patch out to a web server and move on to the next fire. The bug will only affect users with the latest version of Flash Player, 20.0.0.306, in the past that may not be a big deal because most users wouldn’t install every update that was released, but since Flash has had so many security vulnerabilities it is more likely people will have the latest version.

Google Chrome and Flash Player

In the case of Google Chrome though the user being up to date is almost a certainty, because not only does it ship with its own Flash Player, but there is no way via settings to disable Flash Player updates or switch to a different Flash Player version. Don’t get me wrong I think this is great, users should have the most up to date version with all the latest security vulnerabilities patched. If Flash Player didn’t have so many problems it probably wouldn’t have found itself so tightly constrained. Over the last couple years Chrome has slowly removed support for NPAPI plugins in favor of PPAPI, because the latter sandboxes the plugin and makes it more secure. It had been possible to install an NPAPI Flash Player from Adobe onto a system and then disable the built in Chrome Flash Player for purposes of testing or downgrading, you could even enable and disable the different versions of Flash Player from the plugins settings page. However, with the removal of NPAPI support this is no longer an option, which I found out yesterday. The Adobe instructions for installing an alternate version of Flash Player are outdated and still reference the old way. One thing that has changed over the last year is that Adobe now ships a PPAPI version of Flash Player for Chromium browsers, this was the key to solving my problem. I knew that the developers of Chrome may not want other developers to install an NPAPI Flash Player, but they would definitely allow the installation of an older version of a PPAPI Flash Player. They know we gotta debug issues in old versions of Flash Player somehow. Here are those instructions

Downgrade Steps

Download Installer

First you will need to download the installer for the old version of Flash Player you want to use.
  1. All previous version of Flash Player can be found at Flash Player Old Versions Download site
  2. You can find the zip files for the versions in the Flash Player Archives section
  3. Download the version you want to your desktop

Uninstall Flash Player

In order to downgrade Flash Player you must first uninstall any newer versions.
  1. Close any web browsers open on your system
  2. Extract the contents of the zip file.
  3. In the extracted folder, navigate to the folder that doesn’t have “debug” in the name it will contain all the installers and the uninstaller.
  4. Double-click the uninstaller that ends with win.exe. You will be prompte to uninstall the current version of Flash Player for all browsers.
  5. Click Start in the pop up
  6. When it is complete click Done to dismiss the pop up

Install Flash Player for Google Chrome

After Flash Player has been uninstalled, you will need to install the Pepper (PPAPI) Flash Player.
  1. Navigate to the folder where you ran the uninstaller
  2. Run the Pepper installer which is the one that ends with WinPep.exe to install Flash Player for Google Chrome. Flash Player will be installed at the operating system level and will be separate from the version installed with Google Chrome.
  3. Accept the license agreement
  4. Click Install to start the installation
  5. After the installation is done select the Never Check for Updates options and click Done to close the installer

Disable the Chrome Flash Player

Now that you have installed the PPAPI Flash Player into Windows you have to disable the Flash Player that is included in Google Chrome. This is done via a command line argument when launching Google Chrome
  1. Right click on the icon used to launch Google Chrome
  2. Select the Properties option to view the properties for the Shortcut
  3. Go to the Shortcut tab in the properties view
  4. In the Target field add –disable-bundled-ppapi-flash after the closing double quote that wraps the path to chrome.exe. The new value for the target field should be something like this “C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” -disable-bundled-ppapi-flash
  5. Click OK to save the changes

Verify Installed version

Repeat the initial instructions to verify that the version of Flash Player is now correct in your browser
  1. Open up Google Chrome using the shortcut
  2. Go to chrome://plugins
  3. Expand the Details link at the top right corner to see the details of all the plugins
  4. Look at the Flash Player version it should now have a location that points to the Windows Flash Player rather than a Flash Player inside the Google Chrome installation directory.

Monday, February 15, 2016

Flash Problems

Works for Me

Last week I received an email from a QA resource who was getting an error in the Flash Player debugger when performing a very basic action in our Flash application. I quickly looked at the stack trace he provided and tried to reproduce the issue without much luck. I didn’t think anything of it since sometimes QA environments have been known to be suspect.

Fast forward a week and I was pulled into an urgent customer issue, where they were seeing the application become unresponsive when performing some very basic tasks. I logged into the system, where the error was occurring, using IE 11 which has a debugger version of Flash Player and everything worked fine. I then tried it out with Chrome and was easily able to reproduce the issue, same thing with Firefox. I then tried the same thing on a local developer build and got the same results, at first glance there seemed to be a problem with the debugger version of Flash Player. It seemed odd, but they are slightly different versions of Flash Player and it wouldn’t be unheard of.

I spent the next several hours trying pinpoint the issue using Flash Builder and Google Chrome. I was able to comment out some code to make the issue go away, but it wasn’t immediately obvious where things were going wrong. I then remembered that my debugger version of Flash Player was several versions older than the auto updated version in Chrome, version 17 vs version 20. I upgraded the Flash version in IE up to the last release from February 9th, not coincidentally this was the day before the customer saw the issue. To my surprise I was able to reproduce the error and since I was using the debugger version of Flash was shown a stack trace which led me directly to the problem.

The Error

ArgumentError: Error #1508: The value specified for argument RectangleObject is invalid.
                at flash.display::DisplayObject/set scrollRect()
                at spark.components.supportClasses::GroupBase/set scrollRect()
                at spark.components::Group/set scrollRect()
                at spark.layouts.supportClasses::LayoutBase/updateScrollRect()
                at spark.layouts.supportClasses::LayoutBase/scrollPositionChanged()
                at spark.layouts.supportClasses::LayoutBase/set horizontalScrollPosition()
                at spark.layouts.supportClasses::LayoutBase/set horizontalScrollPosition()
                at spark.components.supportClasses::GroupBase/set horizontalScrollPosition()
                at spark.components.supportClasses::GroupBase/set horizontalScrollPosition()

The error was occurring when we were setting the horizontalScrollPosition on a scroller to a very large number (int.MAX_VALUE to be exact). Now I know using this value is not a good idea and should be a red flag, but Flash Player had been okay with it up until the latest version. I installed the version from late January and didn’t have a problem, so it was tied directly to version 20.0.0.306. I looked at the release notes from Adobe, but nothing jumped out at me. It looks like for some reason they added some new validation for the Rectangle object that is passed into DisplayObject.scrollRect() to now throw an error. Of course since Flash Player is closed software I will never know what the limits are for the horizontal scroll position.

The Fix

Since I knew what was going on I was quickly able to commit a fix, which now sets the scroll position to the width of the viewport rather than the maximum integer value. However, the code fix wasn’t going to help the version of the software that had already been released. Since Flash has had so many security problems most browsers now will automatically update, which is why this happened in the first place. The workaround is to uninstall the current version and downgrade to the previous version and shut off automatic updates. In the case of Chrome it is not possible to shut off automatic updates for the Flash Player included with the browser, instead you have to install a separate install of Flash Player, disable the default and enable the new install.

Thursday, February 4, 2016

Functional Decomposition for Kids

My 8 year old is starting to learn coding and was working on a program that would use the graphics turtle to draw a happy face.  It was pretty simple and had a square face, square eyes and a square nose.  I showed him how to copy and paste the code for the first eye to simplify drawing the second eye.  Later he told me how he had to copy the code and paste again to draw the nose.  I recognized an opportunity to teach him about creating functions so I walked him through creating a function to draw a square with a parameter for the length of each side.  We replaced the existing 8 or 9 lines of code with the single call to the function and successfully tested the new function.  

He then turned to me and said, "If I press undo lots of times can I get back to the code without the function?"

I replied, "Yes you can do that, but why would you want to do that?"

He responded, "Because it looks like I did more work this way."