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

_PaginationView compilation with Xcode 12 beta #91

Closed
writing-shed opened this issue Jun 26, 2020 · 39 comments
Closed

_PaginationView compilation with Xcode 12 beta #91

writing-shed opened this issue Jun 26, 2020 · 39 comments
Assignees
Labels
apple-bug compiler-bug wontfix This will not be worked on

Comments

@writing-shed
Copy link

When compiling with Xcode 12 beta the compiler runs out of steam compiling the Combine code on a 16Gb/256Gb MacBook Pro.

The error is on line 249 in
func pageViewController(
_ pageViewController: UIPageViewController,
viewControllerAfter viewController: UIViewController
) -> UIViewController?
The error says: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

@PKizzle
Copy link

PKizzle commented Jun 26, 2020

If you try to circumvent the error by using if-else syntax you will encounter a different one:
error: Abort trap: 6

@writing-shed
Copy link
Author

It would be great if you could fix this because I can't move to Xcode 12 until you do. I have encountered the same problem elsewhere with Xcode 11. It simply requires you to split the code up - for example, in this case, move the extensions into separate files.

@PKizzle
Copy link

PKizzle commented Jun 28, 2020

Were you able to successfully compile by splitting up the code yourself?
BTW: I am not an author of this project, just seeking for help with this issue as well

@writing-shed
Copy link
Author

Not with this issue, but I hit the issue with my own code using Combine (and that was using Xcode 11). I did split that code up and it compiled. I think Combine code must consume lots of resources when compiling.

@YasaminZamaniPro
Copy link

Have the same problem for .flatMap function.
Also waiting..
Thanks

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@writing-shed can you try removing and re-adding SwiftUIX? I suspect that Xcode is not updating to the latest master. This issue was fixed by @Brett-Best with #88.

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

So, it's been compiling fine on my MacBook Pro (15-inch, 2019) after #88, but I've still pushed some more type disambiguation with the latest commit.

I've also moved some delegate code to UIHostingPageViewController. An internal refactor of PaginationView is underway, adding support for dynamic ForEach while still preserving all existing functionality + APIs.

@writing-shed @PKizzle @YasaminZamaniPro please test and confirm whether master compiles for you folks :)

@writing-shed
Copy link
Author

writing-shed commented Jun 29, 2020

I reinstalled the package, did a clean build, but it still fails on the flatMap on lines 195 & 249

@YasaminZamaniPro
Copy link

So, it's been compiling fine on my MacBook Pro (15-inch, 2019) after #88, but I've still pushed some more type disambiguation with the latest commit.

I've also moved some delegate code to UIHostingPageViewController. An internal refactor of PaginationView is underway, adding support for dynamic ForEach while still preserving all existing functionality + APIs.

@writing-shed @PKizzle @YasaminZamaniPro please test and confirm whether master compiles for you folks :)

It works for me now. Thanks a lot! 🤗

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

I still get a compilation error error: Abort trap: 6 when using the PaginationView.
If I remove it from my project it compiles fine.
@YasaminZamaniPro How did you get compilation to work with the PaginationView?

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@writing-shed flatMap has been moved to UIHostingPageViewController - are you seeing the same on your checkout for SwiftUIX? SPM is extremely buggy, even on Xcode 12, and sometimes fails to update packages repeatedly.

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@PKizzle can you create a gist for your checked out version of _PaginationView? I suspect SPM failed to update. If it still fails, free to get on an iMessage chat and fix it (@writing-shed for you as well, if it persists). My iMessage ID is vatsal.manot@yahoo.com.

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

I reinstalled the package, did a clean build, but it still fails on the flatMap on lines 195 & 249

@writing-shed Lines 195 and 249 don't have flatMap anymore - I'm convinced that this is a stale checkout (unfortunately an Xcode bug, please file radars and post the numbers here, I'll duplicate them).

As you can see - this is the latest version of _PaginationView (where lines 195 and 249 are completely different):

Screen Shot 2020-06-29 at 6 55 52 PM

Screen Shot 2020-06-29 at 6 56 01 PM

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@PKizzle could you try building only SwiftUIX? I have a feeling that it traps when building it across modules. You do seem to have the latest version.

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

Building only SwiftUIX works fine. However I am unable to use the PaginationView in my project.

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@PKizzle could you show me your call-site for PaginationView? I think I may know the fix.

@writing-shed
Copy link
Author

This is weird. I just tried Xcode 12 again and I guess it must have reloaded SwiftUIX because the code has been updated, but now I too am getting abort trap 6.

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

That's how I use the PaginationView

var body: some View {
        VStack(spacing: 0) {
            PaginationView(axis: .horizontal, showsIndicators: false) {
                ForEach(self.types.indices) { index in
                    StatisticsCard(id: self.id,
                                   type: self.types[index],
                                   active: self.getActiveBinding(index),
                                   timeFrame: self.$timeFrame)
                        .bounds(self.$bounds)
                        .eraseToAnyView()
                }
            }
            .currentPageIndex(self.$currentPage)
            .frame(maxWidth: .infinity)
            .frame(minWidth: self.bounds.width)
            .frame(minHeight: self.bounds.height)
        }
    }

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@PKizzle I'm pushing a commit with a potential fix in a few minutes, will ping once done here.

@writing-shed
Copy link
Author

Compiling SwiftUIX alone works fine

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

This is the complete error stack dump:

<unknown>:0: error: fatal error encountered during compilation; please file a bug report with your project and the crash log
<unknown>:0: note: Inactive constraints left over?
0  swift                    0x000000010b1daf65 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift                    0x000000010b1d9f65 llvm::sys::RunSignalHandlers() + 85
2  swift                    0x000000010b1db51f SignalHandler(int) + 111
3  libsystem_platform.dylib 0x00007fff737df5fd _sigtramp + 29
4  libsystem_platform.dylib 0x00007ffee8f35ad8 _sigtramp + 18446744071385212152
5  libsystem_c.dylib        0x00007fff736b5808 abort + 120
6  swift                    0x0000000106d5f2bf swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*)::$_1::__invoke(void*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 1151
7  swift                    0x000000010b15a77a llvm::report_fatal_error(llvm::Twine const&, bool) + 234
8  swift                    0x000000010b15a682 llvm::report_fatal_error(char const*, bool) + 50
9  swift                    0x0000000107ac9501 swift::constraints::ComponentStep::take(bool) + 5777
10 swift                    0x0000000107ab7dc4 swift::constraints::ConstraintSystem::solveImpl(llvm::SmallVectorImpl<swift::constraints::Solution>&) + 356
11 swift                    0x0000000107abad34 swift::constraints::ConstraintSystem::solve(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 52
12 swift                    0x0000000107aba154 swift::constraints::ConstraintSystem::solve(swift::constraints::SolutionApplicationTarget&, swift::FreeTypeVariableBinding) + 1140
13 swift                    0x0000000107bf7ff1 swift::TypeChecker::typeCheckExpression(swift::constraints::SolutionApplicationTarget&, bool&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 833
14 swift                    0x0000000107bf7bf8 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 360
15 swift                    0x0000000107cde295 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 12645
16 swift                    0x0000000107cdecda bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::Stmt>(swift::Stmt*&) + 314
17 swift                    0x0000000107cdd3f4 swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) + 8900
18 swift                    0x0000000107cd8c7a bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) + 314
19 swift                    0x0000000107cd754e swift::TypeCheckFunctionBodyUntilRequest::evaluate(swift::Evaluator&, swift::AbstractFunctionDecl*, swift::SourceLoc) const + 2398
20 swift                    0x0000000107ce04fd llvm::Expected<swift::TypeCheckFunctionBodyUntilRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckFunctionBodyUntilRequest, (void*)0>(swift::TypeCheckFunctionBodyUntilRequest const&) + 925
21 swift                    0x0000000107cd86c8 swift::TypeCheckFunctionBodyUntilRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckFunctionBodyUntilRequest>(swift::Evaluator&, swift::TypeCheckFunctionBodyUntilRequest, swift::TypeCheckFunctionBodyUntilRequest::OutputType) + 440
22 swift                    0x0000000107d15db4 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const + 1252
23 swift                    0x0000000107d189c9 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 953
24 swift                    0x0000000107d15744 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) + 164
25 swift                    0x0000000106e98deb swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 6859
26 swift                    0x0000000106d5aee1 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6849
27 swift                    0x0000000106cdfa97 main + 1255
28 libdyld.dylib            0x00007fff735e6cc9 start + 1
29 libdyld.dylib            0x00000000000000d4 start + 18446603338580595724

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@writing-shed @PKizzle just pushed another commit, please try it out and see if it fixes the error: Abort trap: 6. If not, please file a bug with the last copy of SwiftUIX attached in your radar, and pray that Apple fixes it :(

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

@vmanot I am very sorry, it still does not compile 😕

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

I've send a bug report to Apple. Let's hope they'll fix it in an upcoming version of Xcode 12 / Swift 5.3
@vmanot Do you see any Known issue that may be related?

@writing-shed
Copy link
Author

I deleted SwiftUIX and reinstalled but it still doesn't compile - same issue Abort trap 6. Sorry.

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@writing-shed @PKizzle please file bug reports as solving this (especially for a beta version of Xcode) is completely out of scope. Someone actually ran into a similar issue and got their solution through raising an Apple DTS - but you won't be able to do that here as it's a beta setup - the process is unfortunately going to be longer here. I'm marking this as wontfix as cross-module compiler bugs are not a SwiftUIX code issue but a linker issue with Xcode.

That being said, please do post your radar numbers here so that we can get a bunch of people to dupe it and hopefully raise internal priority for Apple's compiler team.

@vmanot vmanot added the wontfix This will not be worked on label Jun 29, 2020
@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

If you experience problems with this feature, disable it by passing -disable-type-fingerprints into the Swift compiler via the Other Swift Flags build setting. If you still experience problems, disable the new dependency infrastructure by passing -disable-fine-grained-dependencies into the Swift compiler via the Other Swift Flags build setting. (59954707)

@PKizzle to answer your question - this may help, though it really shouldn't. But it's a complex compiler, so who knows ¯_(ツ)_/¯

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

The new feedback assistant does not allow for public sharing of the sent information. However if it somehow helps here's the feedback ID: FB7821652

@vmanot The Other Swift Flags sadly did not solve the issue

@Brett-Best
Copy link
Collaborator

@PKizzle can you try this:

var body: some View {
        VStack(spacing: 0) {
            PaginationView<AnyView>(axis: .horizontal, showsIndicators: false) {
                ForEach(self.types.indices) { index in
                    StatisticsCard(id: self.id,
                                   type: self.types[index],
                                   active: self.getActiveBinding(index),
                                   timeFrame: self.$timeFrame)
                        .bounds(self.$bounds)
                        .eraseToAnyView()
                }
                .eraseToAnyView()
            }
            .currentPageIndex(self.$currentPage)
            .frame(maxWidth: .infinity)
            .frame(minWidth: self.bounds.width)
            .frame(minHeight: self.bounds.height)
        }
    }```

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

@Brett-Best You're the best! This works! 🥳

@YasaminZamaniPro
Copy link

I still get a compilation error error: Abort trap: 6 when using the PaginationView.

If I remove it from my project it compiles fine.

@YasaminZamaniPro How did you get compilation to work with the PaginationView?

I just updated the package 🙈
But now I’m afraid to update it again and it won’t work 😁🤦🏻‍♀️

@Brett-Best
Copy link
Collaborator

You don’t have to use AnyView here either, it just needs help figuring out the generic type. I wonder if the requirements of a function builder have changed.

@PKizzle
Copy link

PKizzle commented Jun 29, 2020

@YasaminZamaniPro No worries, it should all work fine. If you don't use a PaginationView at all, there's no issue.
@Brett-Best I guess they changed it in Swift 5.3, but there's no correct error output in the Swift compiler

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@YasaminZamaniPro hahaha, you can update without any issues - I've just added some @inlinable and @usableFromInline optimizations. They solved someone else's compiler issue, and it was the official solution provided by the Apple DTS folks.

@vmanot
Copy link
Member

vmanot commented Jun 29, 2020

@writing-shed does @Brett-Best's solution work for you? If so - then I'll close this ticket.

@writing-shed
Copy link
Author

writing-shed commented Jun 30, 2020

Great stuff - it worked. I added the two AnyView components:

struct PaginatedView: View {
var text:NSAttributedString
var ranges:PageRanges
var orientationSubscriber:OrientationSubscriber
@State private var rect: CGRect = CGRect()
@State var pageNum = 0

var body: some View {
    VStack {
        PaginationView<AnyView>(axis: .horizontal, transitionStyle: .pageCurl, showsIndicators: false) {
            ForEach(ranges, id:\.id) { pageRange in
                PageView(text:self.text,
                         ranges: self.ranges,
                         pageRange: pageRange,
                         orientationSubscriber: self.orientationSubscriber)
                    .eraseToAnyView()
            }
        }.currentPageIndex($pageNum)
    }
}

}

@vmanot
Copy link
Member

vmanot commented Jul 1, 2020

Closing this then, awesome work @Brett-Best!

@vmanot vmanot closed this as completed Jul 1, 2020
@fflisguhcz04697
Copy link

@vmanot I also encounter the compile time-exceed problem when i just import SwiftUIX(without using any module in it) in my project. I suspect that is the a lot of view extension have the same name with SwiftUI's modifier(like background, overlay modifier) confused compiler and slowed it down, finally cause time-exceed. But i can not screen these view extensions, so maybe i can not use this library in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apple-bug compiler-bug wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

6 participants