Macbook Pro Screen Goes Dark on Wakeup

My MacBook Pro should have woken up when I lifted the lid, but all was dark. However, while checking the battery level, I noticed it had woken up. The problem was the backlight wasn’t coming on. Here’s the solution. It isn’t the brightness button either.

Today I learned that there’s a nifty little utility called Maintenance 3.8 out on Apple’s site. You can find it by going to Apple / Mac OS X Software…, and when the web page pops up, type Maintenance in the search box.

It’s an automator script to repair permissions, verify preferences, updating prebindings, do cleanup, update databased, rebuild indexes, empty Trash, and so forth. My guess is it’s much like Onyx.

Deciding to give it a try, I downloaded it, opened the .DMG file, and double clicked the automator icon, selecting Restart when done. And while I got a very little in the confirmation department that things were working, I saw a lot of CPU activity running utilities I was familiar with.

So, with the laptop plugged in, I left to to chug away. I heard the restart sound several minutes later. And, I ignored it.

Later, I picked up my laptop and went to login.

Nothing.

The “breathing LED” on the front was off, and nothing was responding keyboard or mouse wise. The screen was black.

So, I decided to check the battery. Full power.

But then I noticed something. At the steep angle, in the near pitch black of my LCD screen, I saw the login window. What was happening: the backlight wasn’t coming on. Fiddling with the brightness control didn’t help either.

Sure enough, I could make out the cursor once I located where it was.

I tried opening and closing the lid. Nope. Backlight still off.

So, I restarted (as I mentioned, it was operational, I could barely make out the GUI).

The machine sprang to life, showed me the blue background, and right before it went to the login screen, the backlight cut out again, leaving me in pitch black.

Titling the screen back again (with the keyboard sticking up in the air and the screen flat on the table), again I could make out the login box and mouse. I did a restart again.

This time I held down Command-V as it booted. And I watched as it came up, lots of normal diagnostic messages, and then the blue background, and right as the login screen appeared, back to pitch black.

Annoying. But now I’m wondering if all the times I’ve ever woken my laptop after a case where the lid didn’t quite clasp perfectly, was this what was happening — could the machine be up, but the backlight off?

So, one last time, I restarted. Only I held down Command-Option-P-R (four fingers) to reset the power management settings. Several chimes later, I let go, and the machine booted perfectly, and the login box appeared, backlight and all.

I’m hoping that my experience may lead to an additional piece of the puzzle about the Mac waking up funny. I would have never have noticed anything on the screen if I looked at it dead on, as I always do.

It’s fairly well known that if you close the Mac’s lid, but down engage it fully, the lid will pop back up, but not after putting the machine to sleep. At that point, it becomes a little dance with the lid, trying to get the lid back down, so that the machine can see it re-open, and that usually wakes it. But sometimes the screen is still dark, and you have to play with the power button (and if frustrated, hold it down to restart).

Sometimes this same problem manifests when you wake the machine, enter your password, and suddenly everything goes dark. You wiggle the cursor and hit the keys and nothing happens. Caps Lock toggles, but it feels like it’s gone back to sleep.

Well no more. From now on, I’m going to tilt my screen back and see if I’m operational. That way I won’t lose data from an unnecessary restart.

Loathing Dell, Hating Symantec

A password to uninstall Symantec Antivirus…?

In trying to repair a Windows laptop which was acting really slow and appeared to be riddled with problems, I discovered it was running Norton / Symantec Anti-Virus.

Ugh.

It’s been shown with benchmarks that this software kills PC performance. And, in other tests, AVG, which costs less, catches more, without being a resource hog.

So, I go to uninstall Symantec, which can be a chore unto itself. But this time I was greeted with a new source of irritation.

I got a dialog box which said “Please enter the uninstall password”. Great. Just great.

So, given that this OEM laptop had paid support by Dell, I figured I’d ask.

The answer I got back was “I wasn’t aware there was a password to uninstall.”

While Dell was dodging the support question, I found this very helpful article:

http://www.mydigitallife.info/2007/05/05/hack-to-removeuninstall-symantec-norton-antivirus-sav-client-without-password/

In it, it said change the value of this registry key, HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\Administrator Only\Security\, from 1 to 0 with RegEdit.

I tried it. It worked. No problems. Problem solved.

So, I tell the Dell Support person the point is moot, I got past it, and shared the link with him so that future customers with the same problem could have the problem solved. Isn’t that how it’s supposed to be? Learn something, and share — that way others don’t waste time down the path you traveled?

Dell’s tone instantly changed, they didn’t seem happy I got past it. And, then he tells me that Dell support doesn’t give passwords, or tell how to override them, even for OEM installed stuff; they would not be sharing the information, no matter how useful.

So, did they know about the password and just feed me a line? I was certainly left with that impression.

Incidentally, I’ve been told by an IT person, the next time I encounter the password box, enter: symantec

You’ve got to be kidding me.

Firefox Slow Page Load – Solved

Firefox 3 slow? 20 second page load times? Figured out why. And how to fix it.

A co-worker showed me an interesting problem with Firefox today. He loaded a page from our application (running on localhost) and the page content loaded instantly, but the page load itself didn’t end until a time out 20 seconds later. Literally.

Everything we saw a measured from the browser or from the sending application showed that the content was sent in milliseconds, and the page load was just sitting there doing nothing. We were even using the latest Firefox beta.

Other browsers had no such problem.

Turns out, we figured out what was going on using the Tamper Data add-on.

Turns out there was a Connection: keep-alive in the header. When we changed it from keep-alive to close, the browser behaved as expected. That is, it loaded the page instantly.

A little web investigation showed that when you use the keep-alive attribute, you must also use Content-Length: header, which the sending application wasn’t doing.

A quick application tweak to send the content length, and everything ran super spiffy.

Now, if you don’t have access to the application that’s sending you web pages, you can twiddle with the about:config and change the network.http.keep-alive setting to false.

iChat Problems: Fixed

Got Leopard? Find that iChat isn’t working? Do you run Parallels? Guess what, that may be it. What? You’re not running Parallels at the same time you iChat? Not relevant, Parallels has network services active even if the client isn’t. Here’s the workaround to get you chatting…

iChat and Parallels
While trying to iChat using Leopard to a system running Tiger, I ran into a problems that I never had using OS X 10.4 before: bad video quality to downright refusing to connect.

With a little research, I ran across this article and that was enough to resolve the problem.

Here’s how to get iChat working on OS X 10.5
…if you’re running Parallels.

See, turns out that Parallels, I’m using 3.0 Build 5582 (Dec 5, 2007), appears to be running some services, even when the virtual machine is active, that gets in the way of iChat.

Get out of iChat.

Go to Apple / System Preferences…, select Network, and click on Parallels NAT and change the Configure drop down to Off; then go to Parallels Host-Guest an change the Configure drop down to Off. Press Apply.

Get back into iChat and try again. For me, it instantly fixed the problem.

Rebuilding Spotlight’s Index on OS X (Manually)

Got problems rebuilding the Spotlight index on OS X or all you’re getting is an empty list with no files found? Here’s how I reindexed my system using just the Terminal and no special software – turns out there was one small thing that had gotten in the way.

After doing a number of disk clean up and optimizations, I found myself in the circumstance of OS X’s spotlight returning no results. Whether I searched for a keyword in Mail, or by Spotlight using Command-Space, I got no results backs – just an empty list for my troubles.

It turns out there’s a neat utility out there called Rebuild Spotlight Index 2.7 that does all the grunt work for you. Problem is, it didn’t work for me.

What’s going on is actually fairly trivial, and it’s possible to simply do everything via the command line.

The metadata utilities need to run as root, so to see what your drive is up to, you’d enter something like: sudo mdutil -s /

This shows the status on the root volume.

To turn indexing on for a volume, you enter: sudo mdutil -i on /

And, to force Spotlight to rebuild its index, you simply erase the master copy of the metadata stores on the volume like this: sudo mdutil -E /

However, while I did all this, Spotlight was still not building the indexed for me.

Here’s how I solved it, using just the Terminal.
First, I wanted to see the schema file, so I printed it out using to the standard input using: sudo mdimport -X

At the bottom of the schema listing, I say a reference to a schemaLocation, and took a shot in the dark that perhaps that Spotlight’s index rebuilding needed to check data against its schema before it would start. To do that, it might need network access, if not back to the local machine.

And, for good measure, I went to check the date/timestamp on the Spotlight directory using: sudo ls -la /.Spotlight*

While most of the files had the timestamp of when I tried to delete the index, not all the files had the current date and time. Additionally, the file sizes were not growing, a good indication the index was not being rebuilt.

Thinking to myself, “what could be causing network traffic, even internally, not to be working”, I realized that I had just rebooted and PeerGuardian2 was currently active and blocking traffic. This is a great tool for blocking malware and unwanted network visitors, but occasionally it gets in the way. So, I turned it off.

Then, I did the following commands to ensure indexing was on, the spotlight metastore was really gone, and that I wanted it rebuilt:
sudo mdutil -i on /
rm -rf /.Spotlight*
sudo mdutil -E /

The moment I did the last command, this time the system sprung to life, the directory /.Spotlight-V100 was created, and the files inside it were growing quickly. Spotlight on the toolbar showed a progress bar, indicating the system would be done indexing in a bit. The big difference? I turned off the network traffic blocker for a moment.

Dell Inspiron E1505 Mouse Pointer Problem

The cursor on a new Dell Inspiron E1505 laptop with an ATI Mobility Radeon X1400 graphics card running XP Home looks like a vertical bar, not a pointer. Here’s the fix.

Today’s tip comes from John Cook, who reports that upon purchasing a new Dell Inspiron E1505 laptop with an ATI Mobility Radeon X1400 graphics card running Windows XP Home Edition Service Pack 2 (build 2600) and using the “Synaptics PS/2 Port Pointing Device” as a mouse, the cursor appears as a vertical bar.

Unfortunately, there’s nothing on the Internet that tells how to correct the problem.

SOLUTION: The problem is with the hardware acceleration.

Right click the desktop, choose properties, go to the Settings tab, click Advanced, choose the Troubleshoot tab, and slide the slider one notch to the left. Click Ok, then OK.

Mouse Trails Slow Graphics on XP!

Using Microsoft’s Mouse Visualizations, such as mouse trails or show location, well if you’re using a modern system with hardware acceleration, you’re doing so at a very high performance cost. Read on to see why this option should be off.

Today’s trick will give you an astounding performance boost, while at the same time make you just shake your fist at Microsoft.

First of all, to start with, let me say that my Dell Precision 470 (2.8Ghz Dual CPU with hyperthreading on) and 2GB of RAM running XP Pro is …slow. I mean the kind of slow where clicking the Start button takes several seconds to draw the rectangle for the menu.

I have a dual monitor system. I’m using a Dell 2005FPW via DVI at 1680×1050 60Hz as my primary monitor and a Dell 1907FP via analog SVGA/XGA at 1280×1024 60Hz as my secondary. Both are driven by an ATI FireGL V3100 using the latest drivers from ATI’s site for XP Professional, and hardware acceleration is set to full.

I first noticed the severity of the problem when using iTunes 7.3.1.3’s music visualizer. Here’s how playing a simple CD turned into a fantastic diagnostic tool.

With the iTunes visualizer running on the primary monitor, I noticed that when I put the mouse on the secondary monitor the visualizer ran at full speed and was completely fluid. When I put the mouse on the primary screen, even when I wasn’t moving it, the frame rate dropped to about two frames every second (music, however, played fine).

Task Manager, after a violent killing spree, showed a minimal number of processes and services, idle times in the high 90%s, and no interesting page or interrupt activity — but the behavior continued. Opening additional applications didn’t affect performance, as long as the mouse was on the secondary screen.

When I showed this behavior to a friend of mine, Brian Busch, he suggested I turn off mouse trails. And, to humor him, I did. Instantly my system sprung to life and the problem was gone.

That’s when it struck us. Windows XP’s mouse pointer options don’t use hardware acceleration. And to confirm it, I pressed the CTRL button, which showed the location of my mouse. As the little target was drawn around the cursor, the frame rate dropped. When Microsoft’s little visibility animation ended, the system resumed at full speed.

Why was mouse trails on? Because Dell still hasn’t fixed the jumping mouse problem. But I don’t love them enough to kill my system’s responsiveness. Laptop users, beware.

Performance Recommendation: Go to Settings / Control Panel / Mouse, select the Point Options tab, and in the Visibility section uncheck ‘Display Pointer Trails’, ‘Hide pointer while typing, as well as ‘Show location of pointer when I press the CTRL key’ and press OK.

Code Markup for WordPress

I’ve been looking for a decent code markup plugin for WordPress so that I can include source code fragments in WordPress.

Problem is, using <CODE> tag in conjuction with <PRE> injected extra blank lines ( <BR/> ) into the code.

Using Code Markup, I was able to do it.

But there was a trick…

First, the plugin requires that the <code> tag be in lowercase. Internally, I was using uppercase so it’d stand out visually to me. In theory, HTML tags ought to be case insensitive, but the filter required them. I’m going to look at this as a “good thing” since it allows me both worlds. I just wish I found it by a means other than clever guesswork.

Second, if you want spaces preserved, you need to put your code block inside of a <pre> tag. This is actually well documented on the Code Markup site.

Third and finally, do not go sprinkling HTML entities like &amp; in your code; let the filter do it for you.

Fixing Duplicate Menu Items

When duplicate items appear on OS X’s Finder’s Open With pop up menu, there’s something you can do about it. Enter this command…

I’ve recently bumped into a problem where, on occasion, I get duplicate menu items in my right-click pop-up on the OS X desktop, when I select Open With.

Duplicate Menu Items

Turns out this is merely an indicate that the database for LaunchServices needed to be fixed.

And, in fact, this was covered over at Mac OS X Hints a while back. But, given that I had need to look up the command more than once, I present it here.

Inside Terminal, enter:

/System/Library/Frameworks/ApplicationServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

You don’t even need to enter your administrator password, nor do you need to reboot.

OnyX for OS XOnyX allows you to also rebuild the LaunchServices by going to the Maintenance / Reset panel. Though there are a number of other ways to reset launch services for each version of OS X.



Unused local variables, a gotcha that’ll getcha

Removing unused local variables from your programs is actually quite safe, makes your code more readable, and helps get faster compiler times, and can even help produce a tighter, faster, more optimized executable. However, there’s one thing you really need to watch out for…

Recently I attended the No Fluff Just Stuff conference again and learned about a free, fantastic static code analyzer for Java, called PMD. It can use be used standalone or even integrated into many popular IDEs like NetBeans or Eclipse. For the curious, I’d tell you what PMD stands for, but no one really knows; worse yet, I can’t stop myself from typing PDM.

PMD has a nifty rule that allows it to locate Unused Local Variables.

Very quickly I was able to walk through our entire code base, identify things that were assigned to, and subsequently not used, and remove them.

Gotcha #0
The first major hit of the day is that you’ll want to do a Clean on your project before you start. Believe it or not, some project building steps can build intermediate .java, files from your master source code. Problem is, if they appear anywhere inside your project’s directory structure when PMD is making the sweep, they get analyzed to. And you don’t want that.

Gotcha #1
It turns out that there’s a reverse ripple effect in performing this kind of code cleanup and operation. After you’ve removed code, you’ll want to make sure you perform subsequent passes until all concerns are removed.

Take for instance this trivial case:
  B = A;
  C = B;
  // C is unused!

What happens is that once you remove C, it turns out B may no longer be used. Remove B, and it’s even possible A may no longer be used either.

Additionally, this can eventually lead to additional Unused Imports, which dealing with those can also decrease build time.

Gotcha #2 — The Real Evil
Normally, this kind of code clean up is absolutely harmless, although there’s one error of omission that a developer can make which will create problems and cause a silent failure.

Here’s a case where a static code analyzer recommends removing a very important line of code:

boolean doSomething(int x) {
  // Do something very important with x
  return result;
}

...
  boolean result = doSomething( x ); // Do Something Important
  // result not used
...

If the return value from a method isn’t used, then the static analyzer will assume the method doesn’t need to be called, and it will recommend commenting out the line — causing your program to silently break.

This is not a error on the part of the tool!

The error was actually that of the developer for not checking the return results of the method.

To correct the problem with the source code, the developer has three options:

  1. Change the method signature to be of type void.
  2. Throw an exception from the method.
  3. Check the return value of the called method.

Otherwise, the real error is that the method may attempt to do something, fail, and communicate back to the caller than something went wrong, but the caller blindly trusts that things are okay.

If you’re not going to check a return value, you shouldn’t be incurring the overhead of sending one. If the library writer provided one for a reason, then you should be using it.

Conclusion
When a code analyzer makes a recommendation, ask yourself what implied rules about your code the analyzer is assuming. Rather than blaming the tool, the better solution is fixing the source.

It may be best to comment out, rather than deleting, code that initially seems superfluous.

Finally, after a massive code sweep, run those unit tests.