Giter VIP home page Giter VIP logo

Comments (24)

kirirur avatar kirirur commented on September 6, 2024

Hello,

perhaps are you using Chrome as browser? I noticed the same signs some times ago while using that browser. I think it could be something related the page of compression (all the output is sent compressed). It's strange that signs are not displayed with other browsers.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

Hi
i see it on opera and android smartphone. New edge browser don't show it.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

i search around, i hope i find some hints on the web.

from ui.

kirirur avatar kirirur commented on September 6, 2024

Hello,

I've tested the game with the following browsers and the strange chars doesn't come up:
Mac OS X Yosemite 10.10.4

  • Safari 8.0.7
  • Firefox 37
  • Chrome 44
  • Opera 31

Nexus 5 (Android 5.1.1)

  • Chrome

Windows 7 Ultimate

  • Internet Explorer 11
  • Opera 31

I'm downloading Chrome and Firefox on Windows to test also that browsers.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

Hi

that is verry ugly.
I have opera 31 on windows 10 pro and see the signs.
Windows 10 edge browser is ok.

so it looks as the same opera on different win shows not the same.

hmmm...

from ui.

kirirur avatar kirirur commented on September 6, 2024

Hi,

this is really, really strange. I've just tested the game with Opera 31 on Windows 10 Pro (x64) and the signs are not displayed (it's a VM but I don't think it could matter).
screenshot 2015-08-24 17 01 27

from ui.

Dax89 avatar Dax89 commented on September 6, 2024

Hi @kirirur are you testing it on stfc.it? Or in a private server?
I can help you to troubleshoot this issue :)

from ui.

kirirur avatar kirirur commented on September 6, 2024

Hi @Dax89 I'm testing it on stfc.it and AI don't see any trouble. How's the mystery solved? :)

from ui.

Dax89 avatar Dax89 commented on September 6, 2024

Mmmmh
It can be an encoding issue or the browser's cache needs to be deleted.

If the issue is present in Opera only, it can be the page compression feature that leaves some junk at the bottom of the page.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

Hi
it's not the browser cache.
truncatet them and no change.
hmm

from ui.

kirirur avatar kirirur commented on September 6, 2024

Here there's the code in file UI/game/index.php for output compression. It's seems fine to me:

// #############################################################################
// Output compression
$gzip_contents = ob_get_contents();
ob_end_clean();
if( (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) && (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ) {
    $start_gtime = (microtime() + time());
    $compression=1;
    if ($game->player['user_id']<12 && isset($_GET['compression'])) 
        $compression=$_GET['compression']; 
    $gzip_size = strlen($gzip_contents);
    $gzip_crc = crc32($gzip_contents);
    $gzip_contents = gzcompress($gzip_contents, $compression);
    $gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
    $total_gtime = (time() + microtime()) - $start_gtime;
    header('Content-Encoding: gzip');
    echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
    echo $gzip_contents;
    echo pack('V', $gzip_crc);
    echo pack('V', $gzip_size);
    if ($game->player['user_id']<12)
    {
        // Calculate size of the file before / after the compression:
        $gzip_result=floor($gzip_size/1024).'kb / '.floor(strlen($gzip_contents)/1024).'kb<br>'.($total_gtime*1000).' msecs';
        $gzip_size = strlen($gzip_result);
        $gzip_crc = crc32($gzip_result);
        $gzip_result = gzcompress($gzip_result, $compression);
        $gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
        header('Content-Encoding: gzip');
        echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
        echo $gzip_result;
        echo pack('V', $gzip_crc);
        echo pack('V', $gzip_size);
    }
}
else {
    echo $gzip_contents;
}

from ui.

Dax89 avatar Dax89 commented on September 6, 2024

@kirirur
That's tricky, it seems that, for some reason @Caberhagen receives a different header (or longer than expected), you can make this addition to the code, if possible.

Add a console.log() that prints compressed and uncompressed data's length, so it is possible to check if he receives a different length OR (I don't know if this is useful), you can specify Content-Length in the header, as specified in RFC, maybe some browser take care of it:

The Content-Length entity-header field indicates the size
of the entity-body, in decimal number of OCTETs, sent to the recipient or,
in the case of the HEAD method, the size of the entity-body that would have 
been sent had the request been a GET.

 Content-Length    = "Content-Length" ":" 1*DIGIT
An example is
       Content-Length: 3495

Edit: RFC Link http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.13

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

at witch poin i have to add the content-length?
so i can make a test...

from ui.

kirirur avatar kirirur commented on September 6, 2024

I think you need to add it after the first header() call. Something like:

header('Content-Encoding: gzip');
header('Content-length: '.$content_length);

I think.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

tried now.
seem nothing change.
with header('Content-length: .$content_lengt'); the building times have long to loand and display.
with header('Content-length: 3495'); just the bakground from page is showing.

from ui.

kirirur avatar kirirur commented on September 6, 2024

Hi,

the variable $content_length does not exists. It was only an example. I think you need to use one of $gzip_size or something used in this line:

$gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);

I don't know if could be

$gzip_contents = gzcompress($gzip_contents, $compression);
$content_length = strlen($gzip_result);

You need to make some tests, I'm sorry I cannot help more you. :(

from ui.

Dax89 avatar Dax89 commented on September 6, 2024

@Caberhagen:

Yes, Content-Length specifies the amount of data that you are sending to the browser, in this case, the compressed data.

If this doesn't work, try to print the value of $content_length variable (the initialization is explained by @kirirur in the previous post!):

In PHP...

echo $content_length;

...and it is displayed in the webpage, somewhere.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

tried like this:

// Output compression
$gzip_contents = ob_get_contents();
ob_end_clean();

if( (isset($_SERVER['HTTP_ACCEPT_ENCODING'])) && (strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ) {
$start_gtime = (microtime() + time());

$compression=1;
if ($game->player['user_id']<12 && isset($_GET['compression'])) 
    $compression=$_GET['compression']; 
$gzip_size = strlen($gzip_contents);
$gzip_crc = crc32($gzip_contents);
$gzip_contents = gzcompress($gzip_contents, $compression);
$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);

$total_gtime = (time() + microtime()) - $start_gtime;
header('Content-Encoding: gzip');
header('Content-length: '.$content_length);

echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);

if ($game->player['user_id']<12)
{
    // Calculate size of the file before / after the compression:
    $gzip_result=floor($gzip_size/1024).'kb / '.floor(strlen($gzip_contents)/1024).'kb<br>'.($total_gtime*1000).' msecs';
    $gzip_size = strlen($gzip_result);
    $gzip_crc = crc32($gzip_result);
    $gzip_result = gzcompress($gzip_result, $compression);
    $gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
$content_length = strlen($gzip_result);

    header('Content-Encoding: gzip');

    echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
    echo $gzip_result;
    echo pack('V', $gzip_crc);
    echo pack('V', $gzip_size);
}

}

only cange is the building times have long to show.
browser chache truncated. singes still there.

from ui.

kirirur avatar kirirur commented on September 6, 2024

Hello,

if you used that code, I don't see variable $content_length initialization.

I think you need to modify it something like this:

$gzip_contents = substr($gzip_contents, 0, strlen($gzip_contents) - 4);
$content_length = strlen($gzip_contents);

$total_gtime = (time() + microtime()) - $start_gtime;
header('Content-Encoding: gzip');
header('Content-length: '.$content_length);

echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
echo $gzip_contents;
echo pack('V', $gzip_crc);
echo pack('V', $gzip_size);

if ($game->player['user_id']<12)
{
    // Calculate size of the file before / after the compression:
    $gzip_result=floor($gzip_size/1024).'kb / '.floor(strlen($gzip_contents)/1024).'kb<br>'.($total_gtime*1000).' msecs';
    $gzip_size = strlen($gzip_result);
    $gzip_crc = crc32($gzip_result);
    $gzip_result = gzcompress($gzip_result, $compression);
    $gzip_result = substr($gzip_result, 0, strlen($gzip_result) - 4);
$content_length = strlen($gzip_result);

    header('Content-Encoding: gzip');
    header('Content-length: '.$content_length);

    echo "\x1f\x8b\x08\x00\x00\x00\x00\x00";
    echo $gzip_result;
    echo pack('V', $gzip_crc);
    echo pack('V', $gzip_size);
}

Please also read the documentation of involved functions, I don't know them and I don't know if there's something more fitting to obtain the length of compressed data.

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

Yeah, on the most pages the sings are away.
Only on some pages a rest of the sings like this: </
And the rest is fast like ever.

from ui.

kirirur avatar kirirur commented on September 6, 2024

Good do know!

On which pages are you seeing the signs?

Hmm that sign </ seems a truncated HTML tag...

Update: surfing the web I've found this function:

header('Content-Length: '.ob_get_length());

Could you test it and see if it works?

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

portal
spacedock
ship-templates and more.

but i see now at searching the pages.
It's not showing an any page open.
klick more times the same page, and the sings are most there but not on all klicks.
some times no sings on the same page...

wired...

from ui.

kirirur avatar kirirur commented on September 6, 2024

I've found an interesting thread here:

http://stackoverflow.com/questions/3202218/how-does-gzcompress-work

Try to modify:

$content_length = strlen($gzip_result);

into:

$content_length = strlen($gzip_result - 4);

Oh, and please, check if using ob_get_length works better.

Update: found this code example:

<?php 
function print_gzipped_output() 
{ 
    $HTTP_ACCEPT_ENCODING = $_SERVER["HTTP_ACCEPT_ENCODING"]; 
    if( headers_sent() ) 
        $encoding = false; 
    else if( strpos($HTTP_ACCEPT_ENCODING, 'x-gzip') !== false ) 
        $encoding = 'x-gzip'; 
    else if( strpos($HTTP_ACCEPT_ENCODING,'gzip') !== false ) 
        $encoding = 'gzip'; 
    else 
        $encoding = false; 

    if( $encoding ) 
    { 
        $contents = ob_get_clean(); 
        $_temp1 = strlen($contents); 
        if ($_temp1 < 2048)    // no need to waste resources in compressing very little data 
            print($contents); 
        else 
        { 
            header('Content-Encoding: '.$encoding); 
            print("\x1f\x8b\x08\x00\x00\x00\x00\x00"); 
            $contents = gzcompress($contents, 9); 
            $contents = substr($contents, 0, $_temp1); 
            print($contents); 
        } 
    } 
    else 
        ob_end_flush(); 
} 
?>

here: http://php.net/manual/en/function.gzcompress.php

from ui.

Caberhagen avatar Caberhagen commented on September 6, 2024

hi
i think we can cloes this. because i dont find the solution for the last two signs.
but its not realy needet. on most systems the signs are not to see.

from ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.