Thursday, January 30, 2014

Default Desktop Crashes in Ubuntu 13.10 (Saucy) as a VM VirtualBox Guest

I created a guest instance using Ubuntu 13.10 (Saucy) in Oracle VM VirtualBox. When I log in using the default Ubuntu Desktop environment, what I got was a nearly blackscreen after a "compiz crashed" message. My suspicion was that the video card is too  primitive and did not have a reasonable OpenGL support.

To fix the issue, I installed Gnome desktop and logged without any problem in using the Gnome Desktop environment. Since the default desktop environment crashes and I could not get a terminal window to do anything, I had to exit to the console to do the installation. The steps are as follows,

1. Press CTRL-ALT-F1 to switch to the console screen
2. Log in on the console screen
3. Install Gnome desktop environment, by running
         $ sudo apt-get install gnome
4. Kill and restart X or simply reboot the machine, by running
         $ sudo reboot
5. When the Graphical Login screen appears, click on the little
   icon to the right of the user name, and choose any of Gnome
   desktop environment, (Gnome Classic, Gnome Classic ...)
6. Then log in. 
You should be in without any problem.

Web Server Video Support

I was playing with HTML 5 video and encountered the following error in Firefox "no video with supported format and MIME type found" and  that in Internet Explorer "Error: Unsupported video type or invalid file path". The HTML file looks like the following,

<!DOCTYPE html>
<html lang="en">
    <meta charset="utf-8"/>
    <title>HTML 5 Video Example</title>
<h1>Chapter 1: HTML/XHTML</h1>
<h2>Video Example</h2>
<video width="600" height="500"
  <source src="./ex.mp4" type="video/mp4" />
  <source src="./ex.ogv" type="video/ogg" />
  <source src="./ex.webm" type="video/webm" />
  Your browser does not support the video element

The video clip of all 3 formats are at the server and the video plays well at the local machine and fine at another server. After a little bit digging, I found out that the Apache web server has some configuration issue and did not have proper MIME types added. To fix it, simply upload a .htaccess file to the directory where the HTML file is and the .htaccess has the following content,

AddType video/webm .webm
AddType video/mp4 .mp4
AddType video/ogg .ogv

Wednesday, January 22, 2014

Producing PDF document Compatible to Firefox Build-in PDF Viewer

Sometimes Firefox Build-in PDF Viewer does not render some PDF documents well, in which case, the PDF Viewer complains that the PDF document may not be displayed correctly.

A suggested method to correct it is to use external PDF viewer as suggested at Mozilla.

Web searches yield lots of discussions and the discussions are mostly how to find a way to display it correctly just like the above. Those discussions are on the "consumer" side.

However, if you are the on the side of producing and posting PDF documents online, you are probably more interested from beginning with in producing PDF documents that can be displayed correctly by the Firefox Build-in PDF Viewer.

As I investigate, this is not a trivial task. Generally, when the PDF Viewer does not display the document correctly, it is a result that the document contains certain feature which the viewer does not support. To generate a compatible PDF document to the viewer is not to use any unsupported feature that the viewer does not support. However, I failed to locate any document showing which feature is supported and which is not, including the project site at GitHub.

One method that worked for me at least in a few occasions is to use Firefox's Element Inspector.

When a PDF document is not displayed correctly, locate the element that is not displayed correctly or a nearby element to the element that is invisible as a result of not being displayed correctly, right-click the mouse and select "Inspect Element". Examine the element and elements nearby in the Inspector. If you examine them carefully, you may identify something suspicious. For instance, in FireFox 26.0, a PDF file saved in Microsoft PowerPoint is not displayed correctly. Examining it in the Element Inspector, I found out that the location of the problem and suspected that the font "Verdana" somehow could not be displayed correctly, as shown below.

By replacing font "Verdana" by a recognizable font, the problem went away.