Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Crash when using .debug #230

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

Closed
technologybrother opened this issue Jul 21, 2020 · 6 comments
Closed

Crash when using .debug #230

technologybrother opened this issue Jul 21, 2020 · 6 comments

Comments

@technologybrother
Copy link

technologybrother commented Jul 21, 2020

I'm sure it's an obvious mistake on my part and I had no problems before, but I wasn't able to identify the offending code that causes .debug() to result in following error:
crash@2x

As soon as I remove .debug() everything works like charm.

@mbrandonw
Copy link
Member

Hi @ndistqt, thanks for the report! This is a bummer, but we seen some weird behavior in Swift's mirror before, especially when dealing with types from some of Apple's frameworks.

I see the value here is an AXUIElement. Is that being held in your state or your action?

@mbrandonw
Copy link
Member

I may need to see more of your state/actions that is causing this because locally it seems that debugOutput seems to run fine with an AXUIElement, just try out this test:

  func testAXUIElement() {
    let element = AXUIElementCreateApplication(1)

    XCTAssertEqual(
      debugOutput(element),
      """
      """
    )
  }

@technologybrother
Copy link
Author

technologybrother commented Jul 23, 2020

item class@2x

CleanShot 2020-07-23 at 06 32 37@2x

The debugOut function is not found although I have the ComposableArchitecture imported.

@mbrandonw
Copy link
Member

Are you able to reproduce this problem in some code that I can run locally?

Also what is UIElement? It doesn't look like it's an Apple type.

@technologybrother
Copy link
Author

technologybrother commented Jul 24, 2020

"Are you able to reproduce this problem in some code that I can run locally?"

  • I'll try to find out and let you know.

UIElement is from the library AXSwift, which you can find here on github, it's just a wrapper around Apple's accessibility API for better ergonomics.

@stephencelis
Copy link
Member

Hey @ndistqt we took a quick look at AXSwift and it looks like the UIElement custom string convertible conformance does some pretty side-effecty things, like accessing a process ID and calling out to NSRunningApplication:

https://github.com/tmandry/AXSwift/blob/b4db10b2c28583f5c51033166be60a572ff39dcb/Sources/UIElement.swift#L609

In general we think that state needs to consist of simple value types, and as soon as you introduce classes and objects you expose yourself to a lot of undefined behavior that will be difficult to test. If you need parts of these classes in your state we recommend defining structs that hold just the value-based data you care about. It can sometimes be a bit of a pain to add this boilerplate, but it will give you peace of mind that your system is working in a predictable manner.

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

3 participants