GithubHelp home page GithubHelp logo

Comments (10)

phimage avatar phimage commented on June 6, 2024

did you have a strong reference on the Future returned by handleRequest?

from brightfutures.

Thomvis avatar Thomvis commented on June 6, 2024

Sorry to hear you're encountering issues. I can't reproduce the issue myself, it would be helpful if you could provide a crashing test case in a PR if possible.

Could you also try rewriting the method to not use a Promise (as shown at https://github.com/Thomvis/BrightFutures#providing-futures) to see if the crash still happens?

from brightfutures.

adjustnox avatar adjustnox commented on June 6, 2024

I removed all Promises (there were several, nested). Once I switched to using only futures, the crashes stopped.

from brightfutures.

Thomvis avatar Thomvis commented on June 6, 2024

Glad to hear. Would still love to have a reproducing test case to get this issue fixed, so if you have any insights you can share please do :)

from brightfutures.

adjustnox avatar adjustnox commented on June 6, 2024

I have a project I am working on to do just that. Will post back when I get it in place.

from brightfutures.

marchy avatar marchy commented on June 6, 2024

We're getting this exact same issue happening after the Swift 5/Xcode 11/BrightFutures 8.0.0 upgrade.

@adjustnox any luck on getting the reproducible project set up?

@Thomvis We tried converting the following block to Futures:

{
	private var computeFeedItemsTask:Future<[ContentItemVM], Never>?



	// FAILING METHOD
	private func computeFeedItems() -> Future<[ContentItemVM], Never> {
		...

		let existingComputation:Future<[ContentItemVM], Never> = computeFeedItemsTask ?? Future( value: [ContentItemVM]() )
		// FAILING LINE
		let existingComputationPart:String = (existingComputation.isCompleted) ? "finished" : "in progress...."

		...

		computeFeedItemsTask = existingComputation.map( computeFeedItemsQueue.context ){ _ /*(_:[FeedItemVM])*/ -> /*Future<*/[ContentItemVM]/*, NoError>*/ in
			...

			return feedItems

		}.onSuccess( DispatchQueue.main.context ){ (feedItems:[ContentItemVM]) in
			...
		}
	}
}

STACK TRACE:

#0	0x0000000112ebf94f in swift_getAssociatedTypeWitnessSlowImpl(swift::MetadataRequest, swift::TargetWitnessTable<swift::InProcess>*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*, swift::TargetProtocolRequirement<swift::InProcess> const*) ()

#2	0x000000010ee8edaf in AsyncType.isCompleted.getter ()

#3	0x000000010eb491f6 in FeedController.computeFeedItems() at /Users/marchy/Documents/Projects/Happ/Mobile-iOS/Code/Happ.Mobile/Controllers/FeedController.swift:2090

#4	0x000000010eb2c8f5 in FeedController.viewDidLoad() at /Users/marchy/Documents/Projects/Happ/Mobile-iOS/Code/Happ.Mobile/Controllers/FeedController.swift:936

by changing the .map{...} call above to computeFeedItemsTask = Future { complete in DispatchQueue.global().async { ... }} as suggested in the docs, but it actually doesn't even run that far, since existingComputation fails beforehand when trying to access existingComputation.isCompleted when set with its initial empty array value (Future( value: [ContentItemVM]() )).

Here's some outputs of the Future's state:

(lldb) po existingComputation
Async<Result<Array<ContentItemVM>, Never>>(Optional(Swift.Result<Swift.Array<Happ_Mobile.ContentItemVM>, Swift.Never>.success([])))

(lldb) po existingComputation.isCompleted
error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0x0).

(lldb) po existingComputation.result
▿ Optional<Result<Array<ContentItemVM>, Never>>
  ▿ some : Result<Array<ContentItemVM>, Never>
    - success : 0 elements

Seems pretty wild given the implementation of AsyncType::isCompleted seems to be simply:

public extension AsyncType {
    var isCompleted: Bool {
        return result != nil
    }
    ...
}

from brightfutures.

marchy avatar marchy commented on June 6, 2024

Hi @Thomvis @adjustnox did you guys have a chance to look into this by any chance?

This is preventing us from upgrading to Xcode 11 / Swift 5 / iOS 13.
Any insight would be much appreciated

from brightfutures.

adjustnox avatar adjustnox commented on June 6, 2024

It was a hold up for us as well, so we ended up replacing the promises with escaping closures :/

Can't offer any help, I'm afraid.

from brightfutures.

Thomvis avatar Thomvis commented on June 6, 2024

Sorry that this is still an issue. Still not sure what the root cause could be and why this is not reproducible in a new/simple project.

Can you think of any way in which your projects are similarly special? E.g. what is the install method (CocoaPods, Carthage, etc.)

from brightfutures.

adjustnox avatar adjustnox commented on June 6, 2024

Cocoapods for us.

I can say we had several nested promises, which we switched to futures as per earlier suggestions.

from brightfutures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.