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

Fix view frame in portrait when starting iOS app in landscape #1703

Merged

Conversation

MichaelHills
Copy link
Contributor

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • cargo doc builds successfully
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • [ ] Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • [ ] Created or updated an example program if it would help users understand this functionality
  • [ ] Updated feature matrix, if new features were added or implemented

I tested this in simulator + my iPhone 6 using Bevy bevyengine/bevy#87

Might be nice to have at least 1 other person test this as well? Directly on winit rather than on bevy.

This is what the problem looks like. If you start up in portrait mode then everything is fine, auto-rotations all work well. If you start up in landscope mode, its permanently broken even if you rotate.

image

image

@francesca64 francesca64 self-requested a review September 14, 2020 20:48
@francesca64 francesca64 added DS - ios C - waiting on maintainer A maintainer must review this code labels Sep 14, 2020
Copy link
Member

@francesca64 francesca64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, and for giving some love to iOS support!

I maintain winit on mobile; I don't watch this repo (winit generates a ton of notifications), but I'll always come if pinged!

I'll test this out on an iPhone XR and report back.

src/platform_impl/ios/view.rs Show resolved Hide resolved
src/platform_impl/ios/view.rs Outdated Show resolved Hide resolved
src/platform_impl/ios/view.rs Outdated Show resolved Hide resolved
@francesca64 francesca64 mentioned this pull request Sep 14, 2020
6 tasks
@MichaelHills
Copy link
Contributor Author

MichaelHills commented Sep 15, 2020

@francesca64 I have been testing via Bevy, but I think it would be better if I had a pure winit project setup for testing. That way I could more directly test this PR and any other issues I'm having. I looked over the winit examples but couldn't really find a drop-in sample for iOS. I tried window.rs but it's just a black screen which wouldn't really reproduce the issue I'm seeing in Bevy that this PR is about.

Can you recommend any of the examples or do you happen to have a suitable winit example for iOS? Just something like displaying an image would be enough. This would also be useful for me to try to produce a pure winit crash repro for #1705

@francesca64
Copy link
Member

@MichaelHills I actually have something super cool for that exact purpose, but I probably won't be able to get it to you until tomorrow.

@MichaelHills
Copy link
Contributor Author

No worries take your time. I think the code is good now but I'll feel better if I can repro this PR directly on winit. :)

@francesca64
Copy link
Member

So, I made this thing called cargo-mobile, which you can use to generate a minimal winit program that you can run on device. Hopefully the instructions in the README are easy to follow, but I'll answer any questions.

If you want something closer to "something like displaying an image", the wgpu template pack will generate a minimal wgpu program that renders a triangle... but swapping out the winit version being used might be cumbersome, since it's using an older (forked!) version of wgpu. So, it's potentially easier to just work off of the winit template pack, but I'll also be updating the wgpu template pack next week.

@MichaelHills
Copy link
Contributor Author

Nice! This is really cool. I managed to get it building the winit and wgpu examples but had to do the following:

  • cargo mobile init (crashes because I don't have android set up)
  • cargo apple init (to finish the apple setup)

The reason I had to run cargo mobile init first is because it doesn't copy the template code over if you just run cargo apple init by itself and xcodegen complains about ../../src not existing.

The examples run on macOS, but unfortunately it crashes on my phone.

(lldb) bt
* thread #1, stop reason = signal SIGABRT
  * frame #0: 0x00000001009e2418 dyld`__abort_with_payload + 8
    frame #1: 0x00000001009e1a58 dyld`abort_with_payload_wrapper_internal + 100
    frame #2: 0x00000001009e1a88 dyld`abort_with_payload + 12
    frame #3: 0x00000001009a48f8 dyld`dyld::halt(char const*) + 304
    frame #4: 0x00000001009a76e4 dyld`dyld::_main(macho_header const*, unsigned long, int, char const**, char const**, char const**, unsigned long*) + 5396
    frame #5: 0x00000001009a1044 dyld`_dyld_start + 68

@MichaelHills
Copy link
Contributor Author

I ended up running the wgpu triangle example in my manual xcode project that I was using for bevy, and re-produced the issue and confirmed the fix. 👍

image
image

@MichaelHills
Copy link
Contributor Author

Oh and for cargo-mobile, I think it would be great to be able to deploy to the simulator where the dev cycle is a little bit faster.

@francesca64
Copy link
Member

Thanks for trying it out! I'll fix all those problems soon (we're pushing to officially release it in about a month). With regards to the crash, are you using Rust 1.46.0?

Copy link
Member

@francesca64 francesca64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on my iPhone XR and everything looks good! Thanks so much.

@francesca64 francesca64 merged commit c9558c5 into rust-windowing:master Sep 22, 2020
@MichaelHills
Copy link
Contributor Author

I'm on rust 1.48.0 nightly. I could try rolling back to 1.45.2 to see if it resolves the issue?

@francesca64
Copy link
Member

That'd be a big help; I was hitting what appears to be the same issue when I was on 1.46.0, and downgrading to 1.45.2 fixed it for me. You'll also need to cargo clean first, unfortunately... having a second person experience this would be very helpful for when I inevitably have to report this upstream.

@MichaelHills
Copy link
Contributor Author

I updated cargo mobile then switched back to 1.45.2, winit and wgpu templates run fine. Back to 1.48.0 nightly, get the crash again on any of the xamples but the bevy example works in the simulator.

Also while building for aarch64-apple-ios I get a huge amount of spam of this
'+cyclone' is not a recognized feature for this target (ignoring feature)

@francesca64
Copy link
Member

Thanks for trying that! It sounds like I can bisect this more by comparing our build processes.

The spam was an upstream problem, which fortunately doesn't seem to impact the build at all: rust-lang/rust#74427 (comment)

@MichaelHills
Copy link
Contributor Author

When I link the static lib .a to my bevy Xcode project it runs fine. I brought up Xcode and tried to run the cargo mobile project and got this:

dyld: Library not loaded: /Users/mikeh/repos/winit-ios12/target/aarch64-apple-ios/debug/deps/libwinit_ios12.dylib
  Referenced from: /var/containers/Bundle/Application/CC19CF5E-FFA7-4038-AFC2-5A71A52221FD/winit-ios12.app/winit-ios12
  Reason: image not found

This seems to line up with the backtrace I posted earlier referencing dyld. I don't know why it's trying to use a dylib. Anyway hopefully that's enough information to help you narrow it down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - waiting on maintainer A maintainer must review this code DS - ios
Development

Successfully merging this pull request may close these issues.

2 participants