This repository has been archived by the owner. It is now read-only.

Favicon - Sinatra strangeness #362

Closed
paul90 opened this Issue Feb 20, 2013 · 8 comments

Comments

Projects
None yet
2 participants
@paul90
Contributor

paul90 commented Feb 20, 2013

Not had time to debug this yet, so posting in case anybody else is looking into this.

N.B. This problem does not appear to exist on fed.wiki.org (WEBrick), so not sure if the fix already exists, or if that site is still generating the favicon server side.

Running the Sinatra server (on windows - expect all platforms have the same problem). Best explained by looking at the screen shots below (Firefox 18.0.2, IE 9, Chrome) - there is a problem with the favicon - even though there is one stored in the data/status that one is not getting displayed. The client attempts to create a new one, and post back to the server fails (as far as I can see from a quick glance there is no code to process that post!?).

You will also see that the local site favicon is missing from the neighbourhood flags, and IE fails to display the older/new at the top of the page.

fav-icon - sinatra

The accompanying logs (Firefox, IE, then Chrome) - some minor differences as I forgot to clear the browser caches:

127.0.0.1 - - [20/Feb/2013 11:42:19] "GET / HTTP/1.1" 200 2532 0.2450
127.0.0.1 - - [20/Feb/2013 11:42:19] "GET /style.css HTTP/1.1" 304 - 0.0040
127.0.0.1 - - [20/Feb/2013 11:42:20] "GET /js/jquery-ui-1.10.1.custom.min.js HTTP/1.1" 304 - 0.0420
127.0.0.1 - - [20/Feb/2013 11:42:20] "GET /js/jquery-ui-1.10.1.custom.min.css HTTP/1.1" 304 - 0.0020
127.0.0.1 - - [20/Feb/2013 11:42:20] "GET /client.js HTTP/1.1" 304 - 0.0140
127.0.0.1 - - [20/Feb/2013 11:42:20] "GET /favicon.png HTTP/1.1" 200 5 0.0590
127.0.0.1 - - [20/Feb/2013 11:42:22] "GET /images/noise.png HTTP/1.1" 304 - 0.0030
127.0.0.1 - - [20/Feb/2013 11:42:22] "GET /welcome-visitors.json?random=146aed8c HTTP/1.1" 200 8335 0.0500
127.0.0.1 - - [20/Feb/2013 11:42:23] "GET /images/external-link-ltr-icon.png HTTP/1.1" 304 - 0.0040
127.0.0.1 - - [20/Feb/2013 11:42:23] "GET /system/sitemap.json HTTP/1.1" 200 165 0.0360
127.0.0.1 - - [20/Feb/2013 11:42:23] "GET /plugins/favicon/favicon.js?_=1361360543452 HTTP/1.1" 404 213 0.0170
127.0.0.1 - - [20/Feb/2013 11:42:23] "GET /plugins/favicon.js?_=1361360543523 HTTP/1.1" 200 2061 0.0170
127.0.0.1 - - [20/Feb/2013 11:42:23] "POST /favicon.png HTTP/1.1" 404 213 0.0550
127.0.0.1 - - [20/Feb/2013 11:42:25] "GET /favicon.png HTTP/1.1" 200 5 0.0040


127.0.0.1 - - [20/Feb/2013 11:43:59] "GET / HTTP/1.1" 200 2532 0.0670
127.0.0.1 - - [20/Feb/2013 11:43:59] "GET /style.css HTTP/1.1" 200 6773 0.0510
127.0.0.1 - - [20/Feb/2013 11:44:00] "GET /js/jquery-1.7.1.min.js HTTP/1.1" 304 - 0.0510
127.0.0.1 - - [20/Feb/2013 11:44:00] "GET /js/jquery-ui-1.10.1.custom.min.js HTTP/1.1" 200 228147 0.1530
127.0.0.1 - - [20/Feb/2013 11:44:00] "GET /js/jquery-ui-1.10.1.custom.min.css HTTP/1.1" 200 25603 0.0380
127.0.0.1 - - [20/Feb/2013 11:44:00] "GET /js/underscore-min.js HTTP/1.1" 304 - 0.0030
127.0.0.1 - - [20/Feb/2013 11:44:01] "GET /client.js HTTP/1.1" 200 73046 0.0450
127.0.0.1 - - [20/Feb/2013 11:44:02] "GET /crosses.png HTTP/1.1" 304 - 0.0040
127.0.0.1 - - [20/Feb/2013 11:44:02] "GET /images/noise.png HTTP/1.1" 304 - 0.0030
127.0.0.1 - - [20/Feb/2013 11:44:05] "GET /welcome-visitors.json?random=3d5f33fe HTTP/1.1" 200 8335 0.0180
127.0.0.1 - - [20/Feb/2013 11:44:06] "GET /js/images/ui-bg_flat_75_ffffff_40x100.png HTTP/1.1" 404 213 0.0960
127.0.0.1 - - [20/Feb/2013 11:44:06] "GET /js/images/ui-bg_highlight-soft_75_cccccc_1x100.png HTTP/1.1" 404 213 0.0110
127.0.0.1 - - [20/Feb/2013 11:44:06] "GET /js/images/ui-bg_glass_75_e6e6e6_1x400.png HTTP/1.1" 404 213 0.0100
127.0.0.1 - - [20/Feb/2013 11:44:06] "GET /js/images/ui-icons_222222_256x240.png HTTP/1.1" 200 6781 0.0250
127.0.0.1 - - [20/Feb/2013 11:44:06] "GET /favicon.png HTTP/1.1" 200 5 0.0090
127.0.0.1 - - [20/Feb/2013 11:44:06] "GET /images/external-link-ltr-icon.png HTTP/1.1" 200 982 0.0360
127.0.0.1 - - [20/Feb/2013 11:44:07] "GET /plugins/favicon/favicon.js?_=1361360647048 HTTP/1.1" 404 213 0.0110
127.0.0.1 - - [20/Feb/2013 11:44:07] "GET /system/sitemap.json HTTP/1.1" 200 165 0.0070
127.0.0.1 - - [20/Feb/2013 11:44:07] "GET /plugins/favicon.js?_=1361360647857 HTTP/1.1" 200 2061 0.0130
127.0.0.1 - - [20/Feb/2013 11:44:07] "GET /js/images/ui-icons_888888_256x240.png HTTP/1.1" 404 213 0.0070
127.0.0.1 - - [20/Feb/2013 11:44:08] "POST /favicon.png HTTP/1.1" 404 213 0.0100


127.0.0.1 - - [20/Feb/2013 11:44:31] "GET / HTTP/1.1" 200 2532 0.0300
127.0.0.1 - - [20/Feb/2013 11:44:31] "GET /style.css HTTP/1.1" 304 - 0.0080
127.0.0.1 - - [20/Feb/2013 11:44:31] "GET /js/jquery-ui-1.10.1.custom.min.js HTTP/1.1" 304 - 0.0050
127.0.0.1 - - [20/Feb/2013 11:44:31] "GET /js/jquery-ui-1.10.1.custom.min.css HTTP/1.1" 304 - 0.0040
127.0.0.1 - - [20/Feb/2013 11:44:31] "GET /client.js HTTP/1.1" 200 73046 0.0100
127.0.0.1 - - [20/Feb/2013 11:44:32] "GET /welcome-visitors.json?random=94573f37 HTTP/1.1" 200 8335 0.0060
127.0.0.1 - - [20/Feb/2013 11:44:32] "GET /images/noise.png HTTP/1.1" 304 - 0.0080
127.0.0.1 - - [20/Feb/2013 11:44:32] "GET /js/images/ui-bg_flat_75_ffffff_40x100.png HTTP/1.1" 404 213 0.0100
127.0.0.1 - - [20/Feb/2013 11:44:32] "GET /js/images/ui-icons_222222_256x240.png HTTP/1.1" 304 - 0.0040
127.0.0.1 - - [20/Feb/2013 11:44:34] "GET /favicon.png HTTP/1.1" 200 5 0.0110
127.0.0.1 - - [20/Feb/2013 11:44:34] "GET /system/sitemap.json HTTP/1.1" 200 165 0.0110
127.0.0.1 - - [20/Feb/2013 11:44:34] "GET /plugins/favicon/favicon.js?_=1361360674679 HTTP/1.1" 404 213 0.0160
127.0.0.1 - - [20/Feb/2013 11:44:34] "GET /images/external-link-ltr-icon.png HTTP/1.1" 304 - 0.0040
127.0.0.1 - - [20/Feb/2013 11:44:34] "GET /plugins/favicon.js?_=1361360674833 HTTP/1.1" 200 2061 0.0050
127.0.0.1 - - [20/Feb/2013 11:44:35] "POST /favicon.png HTTP/1.1" 404 213 0.0070
@WardCunningham

This comment has been minimized.

Show comment Hide comment
@WardCunningham

WardCunningham Feb 20, 2013

Owner

I'll offer some history but stop short of providing a solution. Sorry.

From early in the project I've felt it important to generate flags for each wiki and that these flags should have a strong family resemblance. (I stopped calling them icons so as to discourage custom designs.) Even as one copies content from other servers, the content refers back to the sites of origin for its flag. Should a site disappear, its flag goes "gray".

@nrn had trouble finding a server-side component that could duplicate the bit manipulation in node that I was doing in ruby. He devised the client-side flag creation mechanism. We were both working against selenium tests at the time and were happy enough to see them working. I have noticed that the flags I generate have a lighter color above a darker color while Nick's are reversed. This was an accident but has remained a subtle clue as to which server created a site initially.

I've since lost track of which server does what now. I do run both ruby and node servers routinely and haven't noticed any trouble creating flags. I don't doubt there are loose ends as this was early code for both of us. Selenium served to unite the two servers but has been cranky in its own way. I've been relying on Mocha for all the work I do with client-server plugins.

If you're thinking of working in this area I would be happy to help or at least share some hopes and dreams as to how we can have more beautiful flags, all built with common code, and no machine code dependencies. This should start with a pure javascript png gradient generator.

Owner

WardCunningham commented Feb 20, 2013

I'll offer some history but stop short of providing a solution. Sorry.

From early in the project I've felt it important to generate flags for each wiki and that these flags should have a strong family resemblance. (I stopped calling them icons so as to discourage custom designs.) Even as one copies content from other servers, the content refers back to the sites of origin for its flag. Should a site disappear, its flag goes "gray".

@nrn had trouble finding a server-side component that could duplicate the bit manipulation in node that I was doing in ruby. He devised the client-side flag creation mechanism. We were both working against selenium tests at the time and were happy enough to see them working. I have noticed that the flags I generate have a lighter color above a darker color while Nick's are reversed. This was an accident but has remained a subtle clue as to which server created a site initially.

I've since lost track of which server does what now. I do run both ruby and node servers routinely and haven't noticed any trouble creating flags. I don't doubt there are loose ends as this was early code for both of us. Selenium served to unite the two servers but has been cranky in its own way. I've been relying on Mocha for all the work I do with client-server plugins.

If you're thinking of working in this area I would be happy to help or at least share some hopes and dreams as to how we can have more beautiful flags, all built with common code, and no machine code dependencies. This should start with a pure javascript png gradient generator.

@paul90

This comment has been minimized.

Show comment Hide comment
@paul90

paul90 Feb 20, 2013

Contributor

I will probably have a brief look, in the first instance to see if this problem is restricted to running the ruby server on windows.

Given that the node server seems to behave correctly - the flag displayed is the one saved on disk, and the favicon plugin is not called. I'm getting a strong feeling that this may well be something about with running the server on windows.

Contributor

paul90 commented Feb 20, 2013

I will probably have a brief look, in the first instance to see if this problem is restricted to running the ruby server on windows.

Given that the node server seems to behave correctly - the flag displayed is the one saved on disk, and the favicon plugin is not called. I'm getting a strong feeling that this may well be something about with running the server on windows.

@paul90

This comment has been minimized.

Show comment Hide comment
@paul90

paul90 Feb 21, 2013

Contributor

We, it wasn't what I thought it might be. Not quite sure what is going on, but have just spotted that I'm getting the error message Image corrupt or truncated: http://localhost:1111/favicon.png in the firebug console, and if I access it directly I get much the same message in the browser.

Deleting the favicon.png file will generate a new flag, that is saved to disk, but next time it is fetched from the server the problem returns.

Using a test page to download favicon.png from the server, all it contains is ‰PNG - so something to do with reading the file??? Nothing obvious yet.

Contributor

paul90 commented Feb 21, 2013

We, it wasn't what I thought it might be. Not quite sure what is going on, but have just spotted that I'm getting the error message Image corrupt or truncated: http://localhost:1111/favicon.png in the firebug console, and if I access it directly I get much the same message in the browser.

Deleting the favicon.png file will generate a new flag, that is saved to disk, but next time it is fetched from the server the problem returns.

Using a test page to download favicon.png from the server, all it contains is ‰PNG - so something to do with reading the file??? Nothing obvious yet.

@WardCunningham

This comment has been minimized.

Show comment Hide comment
@WardCunningham

WardCunningham Feb 21, 2013

Owner

Hmm. Thank you for taking the time to look into this. To be clear, you are having trouble with the Sinatra version, right?

I use Webrick because it avoids some self-reference problems that plague Thin. This could be a limitation in Webrick which is not considered ready for production. I have an outstanding pull request to convert to Puma which promises to be the best of both: production ready and free of self-reference problems.

Owner

WardCunningham commented Feb 21, 2013

Hmm. Thank you for taking the time to look into this. To be clear, you are having trouble with the Sinatra version, right?

I use Webrick because it avoids some self-reference problems that plague Thin. This could be a limitation in Webrick which is not considered ready for production. I have an outstanding pull request to convert to Puma which promises to be the best of both: production ready and free of self-reference problems.

@paul90

This comment has been minimized.

Show comment Hide comment
@paul90

paul90 Feb 21, 2013

Contributor

Yes, this is with the Sinatra version, on Windows.

Digging a bit deeper, it has to be in server/sinatra/stores/file.rb - just tested it with CouchDB and it is not a problem.

Doesn't the file read for blob data needs to be in binary mode? The PNG format contains a EOF character near the start, I expect that is causing the read to stop, and explains why we just get the first few characters.

I will do the code changes, and test it out.

Contributor

paul90 commented Feb 21, 2013

Yes, this is with the Sinatra version, on Windows.

Digging a bit deeper, it has to be in server/sinatra/stores/file.rb - just tested it with CouchDB and it is not a problem.

Doesn't the file read for blob data needs to be in binary mode? The PNG format contains a EOF character near the start, I expect that is causing the read to stop, and explains why we just get the first few characters.

I will do the code changes, and test it out.

@WardCunningham

This comment has been minimized.

Show comment Hide comment
@WardCunningham

WardCunningham Feb 21, 2013

Owner

Ah, that could be it. On OS X and Linux it doesn't matter.

Owner

WardCunningham commented Feb 21, 2013

Ah, that could be it. On OS X and Linux it doesn't matter.

@WardCunningham

This comment has been minimized.

Show comment Hide comment
@WardCunningham

WardCunningham Feb 21, 2013

Owner

There could be some spots where we use / in file paths instead of constructing them piecemeal using portable function calls. Ruby goes to some effort to work around this problem but it doesn't handle every case so the portable software author has to know the system conventions AND the extent that ruby accommodates them.

Owner

WardCunningham commented Feb 21, 2013

There could be some spots where we use / in file paths instead of constructing them piecemeal using portable function calls. Ruby goes to some effort to work around this problem but it doesn't handle every case so the portable software author has to know the system conventions AND the extent that ruby accommodates them.

@paul90

This comment has been minimized.

Show comment Hide comment
@paul90

paul90 Feb 21, 2013

Contributor

There are a number of case in the forums related to reading binary files - this issue only causes a problem on windows, and is solved by opening the file in 'binary' mode.

This only seems to cause a problem on Windows, so would explain why this has not cropped up before.

Not seen any problems with / in paths yet - but I seem to be able to use them rather than \ without problems in Windows 7. Problem with hopping between OS for years. But, will keep an eye open for any.

Contributor

paul90 commented Feb 21, 2013

There are a number of case in the forums related to reading binary files - this issue only causes a problem on windows, and is solved by opening the file in 'binary' mode.

This only seems to cause a problem on Windows, so would explain why this has not cropped up before.

Not seen any problems with / in paths yet - but I seem to be able to use them rather than \ without problems in Windows 7. Problem with hopping between OS for years. But, will keep an eye open for any.

@paul90 paul90 closed this Feb 22, 2013

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.