Closed Bug 1027493 Opened 10 years ago Closed 10 years ago

[dolphin][v1.4]gaia can not get proper screen size

Categories

(Core :: Graphics, defect)

ARM
Gonk (Firefox OS)
defect
Not set
critical

Tracking

()

RESOLVED INVALID
mozilla32
Tracking Status
b2g-v1.4 --- affected

People

(Reporter: ying.xu, Unassigned)

Details

(Whiteboard: [sprd305035])

Attachments

(1 file)

currently, for dolphin v1.4, gaia see screen size is 320X569
But in fact, the screen size of dolphin is 4890X854

I debugged some code, something may were wrong.

1. remember the '60'
AppUnits.h
inline int32_t AppUnitsPerCSSPixel() { return 60; }
inline int32_t AppUnitsPerCSSInch() { return 96 * AppUnitsPerCSSPixel(); }

2. for dophin, the DPI is about 225, so the scale = 1.5
double
nsWindow::GetDefaultScaleInternal()
{
    float dpi = GetDPI();
    // The mean pixel density for mdpi devices is 160dpi, 240dpi for hdpi,
    // and 320dpi for xhdpi, respectively.
    // We'll take the mid-value between these three numbers as the boundary.
    if (dpi < 200.0) {
        return 1.0; // mdpi devices.
    }
    if (dpi < 300.0) {
        return 1.5; // hdpi devices.
    }
    // xhdpi devices and beyond.
    return floor(dpi / 150.0);
}

3.
nsDeviceContext::SetDPI

   CSSToLayoutDeviceScale scale = mWidget ? mWidget->GetDefaultScale()
                                               : CSSToLayoutDeviceScale(1.0);
scale=1.5

  mAppUnitsPerDevNotScaledPixel =
            std::max(1, NS_lround(AppUnitsPerCSSPixel() / devPixelsPerCSSPixel));

mAppUnitsPerDevNotScaledPixel = 40

and mAppUnitsPerDevPixel = 40 too

4. use mAppUnitsPerDevPixel to calculate the screen area
nsDeviceContext::ComputeFullAreaUsingScreen
     outRect->width = NSIntPixelsToAppUnits(width, AppUnitsPerDevPixel());
     outRect->height = NSIntPixelsToAppUnits(height, AppUnitsPerDevPixel());


5. element.h use AppUnitsPerCSSPixel to get pixels, where AppUnitsPerCSSPixel = 60
 int32_t ClientWidth()
  {
    return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().width);
  }

  static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits)
  { return NSAppUnitsToIntPixels(aAppUnits,
             float(AppUnitsPerCSSPixel())); }
Component: GonkIntegration → Graphics
Product: Firefox OS → Core
Target Milestone: --- → mozilla32
Version: unspecified → Trunk
Summary: [dolphin][v1.4]gaia can npt get proper screen size → [dolphin][v1.4]gaia can not get proper screen size
blocking-b2g: --- → 1.4?
(In reply to ying.xu from comment #0)
> currently, for dolphin v1.4, gaia see screen size is 320X569
> But in fact, the screen size of dolphin is 4890X854
> 
> I debugged some code, something may were wrong.
> 
> 1. remember the '60'
> AppUnits.h
> inline int32_t AppUnitsPerCSSPixel() { return 60; }
> inline int32_t AppUnitsPerCSSInch() { return 96 * AppUnitsPerCSSPixel(); }
> 
> 2. for dophin, the DPI is about 225, so the scale = 1.5
> double
> nsWindow::GetDefaultScaleInternal()
> {
>     float dpi = GetDPI();
>     // The mean pixel density for mdpi devices is 160dpi, 240dpi for hdpi,
>     // and 320dpi for xhdpi, respectively.
>     // We'll take the mid-value between these three numbers as the boundary.
>     if (dpi < 200.0) {
>         return 1.0; // mdpi devices.
>     }
>     if (dpi < 300.0) {
>         return 1.5; // hdpi devices.
>     }
>     // xhdpi devices and beyond.
>     return floor(dpi / 150.0);
> }
> 
> 3.
> nsDeviceContext::SetDPI
> 
>    CSSToLayoutDeviceScale scale = mWidget ? mWidget->GetDefaultScale()
>                                                : CSSToLayoutDeviceScale(1.0);
> scale=1.5
> 
>   mAppUnitsPerDevNotScaledPixel =
>             std::max(1, NS_lround(AppUnitsPerCSSPixel() /
> devPixelsPerCSSPixel));
> 
> mAppUnitsPerDevNotScaledPixel = 40
> 
> and mAppUnitsPerDevPixel = 40 too
> 
> 4. use mAppUnitsPerDevPixel to calculate the screen area
> nsDeviceContext::ComputeFullAreaUsingScreen
>      outRect->width = NSIntPixelsToAppUnits(width, AppUnitsPerDevPixel());
>      outRect->height = NSIntPixelsToAppUnits(height, AppUnitsPerDevPixel());
> 
> 
> 5. element.h use AppUnitsPerCSSPixel to get pixels, where
> AppUnitsPerCSSPixel = 60
>  int32_t ClientWidth()
>   {
>     return nsPresContext::AppUnitsToIntCSSPixels(GetClientAreaRect().width);
>   }
> 
>   static int32_t AppUnitsToIntCSSPixels(nscoord aAppUnits)
>   { return NSAppUnitsToIntPixels(aAppUnits,
>              float(AppUnitsPerCSSPixel())); }

But in fact, the screen size of dolphin is 4890X854
something wrong? the screen size of dolphin is 480X854.
> gaia see screen size is 320X569

In what senses?  Is this looking at window.screen.width/height?

If so, those are in CSS pixels, not device pixels.  So if the screen is 480x854 device pixels and window.devicePixelRatio is 1.5, you'd expect to see 320x569.333 for the screen size in CSS pixels.
Flags: needinfo?(ying.xu)
(In reply to Boris Zbarsky [:bz] from comment #2)
> > gaia see screen size is 320X569
> 
> In what senses?  Is this looking at window.screen.width/height?
> 
> If so, those are in CSS pixels, not device pixels.  So if the screen is
> 480x854 device pixels and window.devicePixelRatio is 1.5, you'd expect to
> see 320x569.333 for the screen size in CSS pixels.

there're differences.
gaia use 320X569, but for hardware related modules ,such as display, which use 480X852
so some places of code need to do the scale actions. which may use CPU time very much on mobile platform.

And for app developers , we usually tell them the screen size, not CSS size.
If they're not same, may cause some problems.
for example, a developer usually use a background of fullscreen size, which is 480X852.
not the css size is only 320X569
Flags: needinfo?(ying.xu)
and images for 480X480 screen have been provided under gaia path
but not compiled into the zip file at all.

ffos@ffos2:~/yingxu/7715/gaia/apps/fm/style/images$ ls
app-texture.png             play@2x.png             seekup@2x.png             spinner-FMRadio@2x.png
dial-notches.png            popup-texture.png       selector.png              stop.png
dial-notches@1.5x.png       popup-texture@1.5x.png  selector@1.5x.png         stop@1.5x.png
dial-notches@2x.png         popup-texture@2x.png    selector@2x.png           stop@2x.png
Flags: needinfo?(yang.zhao)
Flags: needinfo?(janjongboom)
Attached image 33.png
Here is a screenshot that displays abnormal on homescreen.But we don't have the STR.Maybe it's related with this issue.Just FYI.
Flags: needinfo?(yang.zhao)
Whiteboard: [sprd305035]
Tim,

I don't think this is a bug here based on the discussions we had before, but my memory is vague. Can you comment if we have a problem here?

Thanks!
Flags: needinfo?(janjongboom) → needinfo?(timdream)
Wayne, ying,

The description and comment 0 along is not a valid bug. You are confusing device pixels with CSS pixels. For historic reason, web applications always see CSS pixels, which are abstract pixels that makes the screens always 160dpi. Obviously your device has way more pixels than 160dpi -- web application will only find out that with |window.devicePixelRatio| and stick the hi-res images in the layout accordingly. Additionally, just like what you found in comment 4, we have special logic in place for packaged app that only packages the images of the right size to save ROM size.

comment 5 is a valid bug and I have seem it somewhere else, but there aren't any STR there either.

Do ni? me if there are specific issues.
Flags: needinfo?(timdream)
So according to comment 7, resolving as invalid here.

Ying, James, if you find out more about what you see in comment 5, which is likely a bug not related to your finding here in comment 0, please file a new bug with STR to track that.

Thanks
Status: NEW → RESOLVED
blocking-b2g: 1.4? → ---
Closed: 10 years ago
Resolution: --- → INVALID
Yang, please file a new bug to track, thanks.
Flags: needinfo?(yang.zhao)
(In reply to James Zhang (Spreadtrum) from comment #9)
> Yang, please file a new bug to track, thanks.
Ok,I filed a new bug for comment #5 
https://bugzilla.mozilla.org/show_bug.cgi?id=1031173
Flags: needinfo?(yang.zhao)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: