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."

Saturday, January 16, 2016

Apple Product Naming Over the Last 10 Years

Over the last ten years Apple has released four new product categories: iPhone, iPad, Apple Watch and Apple TV. In each of these categories they have had various naming conventions for the products. The name of the initial offering for each category was usually straightforward, well with the exception of the Apple Watch and its various editions. As the products started to branch out the names got slightly more inconsistent.

iPhone

The original iPhone was followed by the iPhone 3G, because of support for 3G cellular networks, which interestingly also has caused some people to refer to the original iPhone as the iPhone 2G. After that was the iPhone 3GS, followed by the fourth release, the iPhone 4. It was the third form factor, but fourth phone model. Since then the pattern of incrementing the number for each new form factor and adding an S for the intermediate years. In 2013, the newest phone was named iPhone 5S, but another new C designation was added for the new colorful iPhone 5C, which had all of the internals of the iPhone 5, but had a polycarbonate case. It isn't clear why the new phone was released, perhaps to differentiate it more from the S model or maybe to try and add more demand for the year old model by making it seem "new". In 2014, a new form factor was introduced with the expected increment in the number, however a new larger screen became available adding the new + identifier, for the iPhone 6+. Most recently in 2015 the introduction of the iPhone 6S and iPhone 6S+ continued the tradition of using the S identifier for the second year of the same form factor. However, unlike last time a new C model was not introduced along side the S model and instead the iPhone 6 remained available.
GenerationMarketing NameAlt. Names
1iPhoneiPhone 2G
2iPhone 3G
3iPhone 3G S
4iPhone 4
5iPhone 4 S
6iPhone 5
7iPhone 5 S
8iPhone 6
9iPhone 6 S

iPad

The original iPad was followed by the iPad 2 in March 2011. So far so good, right? The following year a new iPad was announced with the same form factor, but a new retina display. Apple referred to this model as "new iPad", however most people refer to it as the iPad 3 or 3rd generation using the old iPod naming convention. A short seven months later Apple announced the next iteration of the iPad, which was marketed as "iPad with Retina Display". The form factor remained the same as its predecessor, this version was also referred to as iPad 4 or 4th generation. At the same event Apple also announced a new smaller iPad called the iPad Mini, similar to the branding used on the first smaller iPod Mini. In 2013, a new thinner form factor with a smaller bezel was introduced with a new name, the iPad Air. The Air name had been used for the ultra portable line of MacBooks first introduced in 2008, which were much smaller than the existing MacBook and MacBook Pro models. The overall size of the device was noticeably smaller compared to the previous models, which may be the reason for the new naming convention. At the same event in 2013 the new "iPad Mini with Retina Display" was announced as the successor to the iPad Mini. The following year the iPad Air 2 and iPad Mini 3 were announced, while the form factors were the same as the previous generation the internals were upgraded. At this time the previous generation iPad Mini with Retina Display"" was given a new designation of iPad Mini 2. In September 2014, Apple announced the highly anticipated iPad Pro with a new 12" screen. At this point Apple seems to have settled on using Mini, Air and Pro as the names for the different screen sizes, they then just stick a number on the end based on which generation of the current name.
GenerationMarketing NameAlt. Names
1iPad
2iPad 2
3new iPadiPad 3, 3rd Generation
4iPad with Retina DisplayiPad 4, 4th Generation
5iPad Air
6iPad Air 2

MacBook

I could go over the many various names for Apple laptops over the years, PowerBooks, iBooks and MacBooks, but this will focus on the MacBook. The first MacBook was the MacBook Pro announced in January of 2006. The polycarbonate MacBook was announced the following May. These two were updated once or twice a year until January 2008 when the new thinner MacBook Air was announced. 

Going forward the three different lines have been maintained with the MacBook Air being the smallest model, the MacBook Pro being larget more performing model and the MacBook being the same size as the MacBook Pro, but cheaper and less powerful. In 2012, things changed a little with the introduction of the Retina Display on the MacBook Pro, as these were rolled out there was a choice between the MacBook Pro and the MacBook Pro with Retina Display. At some point the MacBook disappeared and the MacBook Pro 13" was added. Most recently in 2015, the new MacBook with Retina Display, was released, which is actually smaller than the MacBook Air. Unlike iPhones and iPads the various MacBooks of the same line are differentiated using the date they were initially released.

The Apple Devices

The other devices I will mention are the Apple TV and Apple Watch. Both of these start with Apple, well technically there name starts with the Apple logo. The Apple TV was originally introduced as iTV, but was changed before it shipped. It has had a few different iterations, but generally it is just referred to using an understood "generation" nomenclature. The Apple Watch is still on the first generation, so whether it gets the numbered system like the iPhone and iPad or if it just gets the generally accepted "generation" nomenclature hasn't been determined yet.

In Conclusion

It is often confusing and not logical the way these various products have been named, but I think it is bound to happen in an industry where it is difficult to foresee how a product category may change. It is also hard to judge some of these names without knowing what products are to come. I think some of the naming has to do with the target consumer and market. The phones are much more mainstream and they need a clear naming convention so the average consumer can figure out the difference between the various models.

As for the use of Apple in the front of Apple Watch, I think this is the new direction and if they could go back in time I think the iPhone would have been named Apple Phone. The i naming thing seems so dated and has also opened up a pandora's box for third party companies naming their stuff with the i prefix. Using the Apple prefix also prevents any trademark issues like they experienced with the iPhone.

Finally, I am really interested to see when they decide to drop the numbering scheme from the iPhone and iPad names. It will sound completely ridiculous when they release the iPhone 11 or iPad Mini 14. I wonder if by then the products will be so mature that it will be released in a similar to manner as the MacBook, with random releases every year having only minor performance improvements with major form factor changes every 4-5 years.

UPDATE: After more consideration I wonder if the numbering scheme is also a result of how the specs of the mobile devices are somewhat obfuscated from consumers.  If you try to buy a MacBook Pro they don't break them down into different numbers even when there are a couple generations available, instead we can rely on the old processor speed, storage, memory and display quality properties to pick the device that is right for you. Perhaps it is just another side effect of the simplification of computing devices, if the operating system is going to be easier to use than it only makes sense that buying one should be less confusing too.

Friday, January 8, 2016

Bad Default Program for CMD and Bat Files

This week I received a .cmd file from my boss and when I downloaded it to my Windows 7 laptop and tried to double click on it in Windows Explorer, it just opened up in a text editor.  I am assuming at some point I must have changed the default program for .cmd files to be the text editor, probably because we typically just use .bat files for that type of action.  It turns out if you change the file association for one of the standard "executable" types of files it is a little tricky to get it correct.  I initially tried updating the file association in the Default Programs control panel, which didn't work.  I then attempted to manually edit the registry to remove the file association as recommended by some sites, which also didn't work.  I continued researching the issue and the general consensus was that you had to make several registry edits to get things straightened out, but I am not a huge fan of just randomly running registry edits from random sites on the internet.  Eventually I found this page on the Microsoft forums, Can't execute bat or cmd files opens Notepad. It mentioned bat_fix_w7.reg, but it wasn't available on the page, so after a little more searching I found winhelponline's File Association Fixes for Window 7, from here I was able to download a registry editor files that would correct my issue.  I quickly read through the file in a text editor and it appeared to be mostly updating the HKEY_CLASSES_ROOT\.cmd and  HKEY_CLASSES_ROOT\cmdfile to put in new values for cmd files.  It also removed any existing file association for the .cmd extension.  With some hesitation I ran the command and I was able to successfully run my .cmd files from Windows Explorer again.