Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] orientation listener on javascript #2636

Closed
jsfan3 opened this issue Dec 7, 2018 · 8 comments
Closed

[BUG] orientation listener on javascript #2636

jsfan3 opened this issue Dec 7, 2018 · 8 comments
Assignees
Milestone

Comments

@jsfan3
Copy link
Contributor

jsfan3 commented Dec 7, 2018

This bug is strictly related to #2628 (I think that it's the same), but it's a much simpler to investigate, because the following test case is composed by few lines of code.

In short: the following code works on the native apps and on the Javascript port when run on Android, but it produces weird effects when it's run on iPhone. So, to reproduce the bug, simply build to Javascript the following code and test it on Chrome on iPhone, while trying to rotate the device.

Form outer = new Form("OuterForm", new BorderLayout(BorderLayout.CENTER_BEHAVIOR_CENTER_ABSOLUTE));
        Label innertext = new Label("Screen size: " + Display.getInstance().getDisplayWidth() + " * " + Display.getInstance().getDisplayHeight());
        Form inner = new Form("InnerForm", BoxLayout.y()) {
            @Override
            protected Dimension calcPreferredSize() {
                return new Dimension(Display.getInstance().convertToPixels(90), Display.getInstance().getDisplayHeight());
            }
        };
        inner.add(innertext);
        outer.add(BorderLayout.CENTER, inner);
        outer.show();

        outer.addOrientationListener(l -> {
            innertext.setText("Screen size: " + Display.getInstance().getDisplayWidth() + " * " + Display.getInstance().getDisplayHeight());
            innertext.repaint();
        });
@codenameone codenameone added this to the Version 6.0 milestone Dec 8, 2018
@shannah
Copy link
Collaborator

shannah commented Dec 10, 2018

Can you provide more information about the problem. I built this app and ran it in iOS safari and chrome, and it seems to work fine.
img_4525
img_4526

@jsfan3
Copy link
Contributor Author

jsfan3 commented Dec 10, 2018

Have you tried to rotate the device multiple times?

@shannah
Copy link
Collaborator

shannah commented Dec 10, 2018

4 or 5 times. How many does it take to make it fail?

@jsfan3
Copy link
Contributor Author

jsfan3 commented Dec 10, 2018

Few times... I'm going to record a video.

@jsfan3
Copy link
Contributor Author

jsfan3 commented Dec 10, 2018

This is the video: https://www.informatica-libera.net/videoLavoro/testJavascriptRotationOnIphoneX.mp4

Tested the above code, built as Javascript, on Chrome on iPhoneX.

@shannah
Copy link
Collaborator

shannah commented Dec 12, 2018

I've managed to reproduce it. So far only occurring in Chrome. Not in Safari. Looking into it further

@shannah
Copy link
Collaborator

shannah commented Jan 4, 2019

For some reason, Chrome on iOS doesn't yet have the updated window/document size inside the window "resize" event, which we use to trigger the canvas resize. I have resolved this issue in my tests by adding a 1ms delay between the "resize" event and when we update the canvas size.

This will be part of the next server update (next Friday).

@shannah shannah closed this as completed Jan 4, 2019
@jsfan3
Copy link
Contributor Author

jsfan3 commented Jan 4, 2019

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants