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

Initial NavigationView implementation #130

Merged
merged 38 commits into from
Jul 22, 2020
Merged

Initial NavigationView implementation #130

merged 38 commits into from
Jul 22, 2020

Conversation

j-f1
Copy link
Member

@j-f1 j-f1 commented Jun 30, 2020

Fixes #129.

Current status:

  • Displays the navigation links
  • Accessible
  • NavigationLink is clearly clickable
  • Destination is visible after clicking

@j-f1 j-f1 added the SwiftUI compatibility Tokamak API differences with SwiftUI label Jun 30, 2020
@j-f1 j-f1 marked this pull request as draft June 30, 2020 19:12
@j-f1
Copy link
Member Author

j-f1 commented Jul 1, 2020

Decided to try to refactor the Proxy structs into one shared type but ran into feedback-assistant/reports#128 ¯\_(ツ)_/¯

@j-f1
Copy link
Member Author

j-f1 commented Jul 1, 2020

It looks like SwiftWebUI uses Combine to handle the NavigationView. Is it OK to add that as a dependency?

@MaxDesiatov
Copy link
Collaborator

Yeah, sure, I have a version here tailored for SwiftWasm just for this occasion 😉

@MaxDesiatov
Copy link
Collaborator

Also going to be handy for things such as #141

@j-f1
Copy link
Member Author

j-f1 commented Jul 1, 2020

Turns out I didn’t end up needing it anyway! Simply overwriting the wrappedValue of a Binding is sufficient.

@j-f1
Copy link
Member Author

j-f1 commented Jul 2, 2020

I merged in main and now I’m getting a crash:

[Error] Unhandled Promise Rejection: RuntimeError: Out of bounds memory access (evaluating 'a._start()')
Stack
	<?>.wasm-function[searchInConformanceCache(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*)]
	<?>.wasm-function[swift_conformsToSwiftProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, __swift::__runtime::llvm::StringRef)]
	<?>.wasm-function[swift_conformsToProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*)]
	<?>.wasm-function[swift_conformsToProtocol]
	<?>.wasm-function[_conformsToProtocols(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetWitnessTable<swift::InProcess> const**)]
	<?>.wasm-function[_dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags)]
	<?>.wasm-function[swift_dynamicCastImpl(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags)]
	<?>.wasm-function[swift_dynamicCast]
	<?>.wasm-function[$s11TokamakCore7AnyViewVyACxcAA0D0RzlufcACypcfU_]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC6render13compositeViewQrAA016MountedCompositeG0CyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15MountedHostViewC5mount4withyAA15StackReconcilerCyxG_tFyAA0cE0CyxGXEfU0_]
	<?>.wasm-function[$s11TokamakCore15MountedHostViewC5mount4withyAA15StackReconcilerCyxG_tFyAA0cE0CyxGXEfU0_TA]
	<?>.wasm-function[$s11TokamakCore11MountedViewCyxGs5Error_pIggzo_ADsAE_pIegnzo_AA8RendererRzlTR]
	<?>.wasm-function[$s11TokamakCore11MountedViewCyxGs5Error_pIggzo_ADsAE_pIegnzo_AA8RendererRzlTRTA]
	<?>.wasm-function[$sSTsE7forEachyyy7ElementQzKXEKF]
	<?>.wasm-function[$s11TokamakCore15MountedHostViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore20MountedCompositeViewC5mount4withyAA15StackReconcilerCyxG_tF]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufc]
	<?>.wasm-function[$s11TokamakCore15StackReconcilerC4view6target8renderer9schedulerACyxGqd___10TargetTypeQzxyyycctcAA4ViewRd__lufC]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufc]
	<?>.wasm-function[$s10TokamakDOM11DOMRendererCyACx_13JavaScriptKit11JSObjectRefCtc0A4Core4ViewRzlufC]
	<?>.wasm-function[main]
	<?>.wasm-function[__original_main]
	<?>.wasm-function[_start]
	wasm-stub
	_start
	(anonymous function) (index.esm.js:182:184)
	(anonymous function) (dev.js:64)
	asyncFunctionResume
	(anonymous function)
	promiseReactionJobWithoutPromise
	promiseReactionJob

@MaxDesiatov
Copy link
Collaborator

This might be a SwiftWasm bug, I'd recommend trying with more recent (or older) snapshots, but the most recent snapshots broke SwiftPM on macOS as far as I remember. The process of picking a correct snapshot probably is going to be tedious, so maybe it would be better to wait until I get most recent snapshots fixed, IDK 🤔

@MaxDesiatov
Copy link
Collaborator

Also, IDK if there actually is a snapshot of SwiftWasm that doesn't have this broken, would be great to isolate what exact code is actually causing this.

@j-f1
Copy link
Member Author

j-f1 commented Jul 3, 2020

Bug remains present on the latest SwiftWasm wasm-DEVELOPMENT-SNAPSHOT-2020-07-02-a.

Overall, repros on:

  • wasm-DEVELOPMENT-SNAPSHOT-2020-07-02-a
  • wasm-DEVELOPMENT-SNAPSHOT-2020-06-12-a
  • wasm-DEVELOPMENT-SNAPSHOT-2020-06-02-a

It fails to build on wasm-5.3-SNAPSHOT-2020-07-02-a with error: 'stdlib.h' file not found.

@MaxDesiatov
Copy link
Collaborator

Oh, interesting, my understanding was that SwiftPM is still broken for wasm-DEVELOPMENT-SNAPSHOT-2020-07-02-a on macOS, or did you try that on Linux?

@j-f1
Copy link
Member Author

j-f1 commented Jul 3, 2020

I tried it on macOS. What do you mean be SwiftPM being broken?

@MaxDesiatov
Copy link
Collaborator

I was relying on the CI logs in swiftwasm/swift#1233 in the "Run smoke tests on macOS" step, which fails with a weird error I didn't have time yet to look into. But I'm happy that it actually works, means I only need to fix the way it's used on CI, I guess.

@j-f1
Copy link
Member Author

j-f1 commented Jul 3, 2020

I sometimes get weird errors but sometimes it works just fine ¯\_(ツ)_/¯

@MaxDesiatov
Copy link
Collaborator

Please report the errors to the main swiftwasm/swift project, if you don't mind. I guess nuking the .build/wasm32-unknown-wasi directory may produce a cleaner environment for reproduction.

@j-f1
Copy link
Member Author

j-f1 commented Jul 3, 2020

swiftwasm/swift#1362 & swiftwasm/swift#1363

@MaxDesiatov
Copy link
Collaborator

It’s getting chopped off because box-sizing is not set to border-box or padding-box.

Sorry, I'm not sure if this PR is fully ready for review then, and if not, do you plan to address this, or maybe land that as a separate PR?

@j-f1
Copy link
Member Author

j-f1 commented Jul 20, 2020

That’s a separate issue since it also reproduces on main it’s just less obvious because it stretches all the way across the screen.

@MaxDesiatov MaxDesiatov requested a review from carson-katri July 20, 2020 21:15
MaxDesiatov
MaxDesiatov previously approved these changes Jul 20, 2020
Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Great stuff, thank you so much 👏

@j-f1
Copy link
Member Author

j-f1 commented Jul 20, 2020

Did some testing and it looks like the @ViewBuilder tricks you suggested crash with an EXC_BAD_ACCESS (code=1, address=0x0) on iOS 13/macOS 10.15. Do you want to keep support for them for now or is it ok to require 10.16/14 betas?

@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented Jul 20, 2020

Probably ok to require them, unless you find it more convenient to develop and test on iOS 13/macOS 10.15. I don't have Big Sur installed and don't intend to until it's stable enough, and testing with an iOS 14 simulator is fine for me personally. @carson-katri what do you think?

@carson-katri
Copy link
Member

I have a machine with Big Sur, so no problems here.

@j-f1
Copy link
Member Author

j-f1 commented Jul 20, 2020

I’d rather have things working on my existing devices (13/10.15) and the AnyView stuff isn’t a huge issue.

@MaxDesiatov MaxDesiatov mentioned this pull request Jul 21, 2020
4 tasks
Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

This is great stuff and looks good to me 👍 Apologies for all the delays, but would you be able to resolve the conflicts?

MaxDesiatov
MaxDesiatov previously approved these changes Jul 22, 2020
Copy link
Collaborator

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Thanks 🙌

@MaxDesiatov MaxDesiatov changed the title Initial NavigationView implementation Initial NavigationView implementation Jul 22, 2020
carson-katri
carson-katri previously approved these changes Jul 22, 2020
@MaxDesiatov
Copy link
Collaborator

Conflicts 🙈

@carson-katri
Copy link
Member

carson-katri commented Jul 22, 2020

I resolved it. Sorry, I merged App protocol before this, that's on me.

@carson-katri carson-katri dismissed stale reviews from MaxDesiatov and themself via 46ab7b9 July 22, 2020 21:07
@carson-katri carson-katri self-requested a review July 22, 2020 21:09
@j-f1 j-f1 merged commit ac50208 into main Jul 22, 2020
@j-f1 j-f1 deleted the navigation branch July 22, 2020 21:12
MaxDesiatov pushed a commit that referenced this pull request Aug 5, 2021
`Toolbar` is new in SwiftUI. It is coupled fairly closely with `NavigationView`, so this should be integrated with that somehow (#130). It was made similar to macOS which allows more than a leading/trailing `ToolbarItem`.

Resolves #316.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SwiftUI compatibility Tokamak API differences with SwiftUI
Development

Successfully merging this pull request may close these issues.

NavigationView/NavigationLink
3 participants