question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Width and height constraint inverted in android chrome

See original GitHub issue

It’s weird but I’m testing this library with a resized camera (wich is not working on iOS (#244)

I’m testing on an android device using chrome, and on a windows computer using also chrome, with a mobile view.

If i set the constraints:

constraints: {
         width: 100,
         height: 300
       }

In the computer I get this:

lector-pc

Which is the expected behaviuour, since it’s height is bigger than the width. But when I open it on the android chrome I get:

lector-android

Same code for both.

Don’t know what is happening, and I don’t know which is the correct approach for resizing, since this doesn’t work on Safari and It has this behaviour on chrome for PC and Android.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
poliandercommented, Dec 20, 2017

You’ll have to fix that on your side, e.g. I’m using a function like this one in my application:

fixOrientation = function(w, h)  {
    var md = new MobileDetect(window.navigator.userAgent),  d = {
        w: w,
        h: h
    };

    if (md.phone() || md.tablet()) {
        if (window.matchMedia('(orientation:portrait)').matches) {
            if (md.userAgent() !== 'Safari') {
                d.w = h;
                d.h = w;
            }
        }
    }

    return d;
}

// ...

var dim = fixOrientation(640, 480);

Quagga.init({
    constraints: {
        width: dim.w,
        height: dim.h
    }
});

1reaction
osieckiAdamcommented, Jan 17, 2021

Hey @geersch this is very old discussion but today I had exactly the same issue and I managed to solve it, so I will leave this for the potential future use. In my case changing aspectRatio helps, by default its 1:2, so I changed it to 1:100 and it looks correct now, see example configuration below:

inputStream: {
  type: "LiveStream",
  constraints: {
    facingMode: "environment",
    width: parseInt(elemWidth),
    aspectRatio: {min: 1, max: 100}
  },
  target: elem
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS height messed up in Android chrome - Stack Overflow
It Looks like that Chrome for Android is having some problems .. so if the page can scroll horizontally, it will scroll vertically...
Read more >
Constraints | Android Developers
The height and width requirements can be reversed, with a height of up to 18 bits and width ... Creates constraints for fixed...
Read more >
Customize an image | Jetpack Compose - Android Developers
Clip an Image composable to a shape. // We create an Oval that starts at ¼ of the width, and ends at ¾...
Read more >
Compose modifiers - Jetpack - Android Developers
If the modifiers order is reversed, the space added by padding does not react to ... The parent will see the child's width...
Read more >
VectorDrawable | Android Developers
android :name: Defines the name of this vector drawable. android:width: Used to ... android:height: Used to define the intrinsic height of the drawable....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found