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

EnvironmentObject EXC_BAD_ACCESS #52

Open
shial4 opened this issue Jan 10, 2020 · 6 comments
Open

EnvironmentObject EXC_BAD_ACCESS #52

shial4 opened this issue Jan 10, 2020 · 6 comments

Comments

@shial4
Copy link
Contributor

shial4 commented Jan 10, 2020

EnvironmentObject value passed in view hierarchy changed on server callback crashes serwer.

error: warning: couldn't get required object pointer (substituting NULL): Couldn't load 'self' because its value couldn't be evaluated

error: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffffd).

Inside

guard let box = slot.pointee.value as? StateValueBox else {
        fatalError(
          "@EnvironmentObject value is pointing to a different box type!")
      }

To reproduce fetch changes from tag #52
https://github.com/shial4/SWUI-NextUp/tree/%2352

  1. build & run.
  2. Select sign in tab
  3. Enter credentials (test@test.com, test123456)

Click continue -> nothing will happen at first click (no clue why) wait like 5 seconds and click it second time. View will change and serwer will crash.

@shial4
Copy link
Contributor Author

shial4 commented Jan 10, 2020

Found this

expression produced error: error: /var/folders/gg/hfgx153d4rl12h2fw1wtw0rw0000gn/T/expr14-87ee3c..swift:1:76: error: 'EnvironmentObject' is not a member type of 'SwiftWebUI'
Swift._DebuggerSupport.stringForPrintObject(Swift.UnsafePointer<SwiftWebUI.EnvironmentObject<MyApp.AccessToken>.StateValueBox>(bitPattern: 0x1051cdb50)!.pointee)

@shial4
Copy link
Contributor Author

shial4 commented Jan 10, 2020

Side note. If I refresh page from within browser it does render desired view. Do not have to click it twice. What's the difference? Why it is not reloading page on the 1st click & 1st environment variable (observable)?

@shial4
Copy link
Contributor Author

shial4 commented Jan 10, 2020

Is there something wrong with Ajax?
Those are two loga I do receive after onTapAction.

POST /handle?wosid=52B8CAE2-6481-4589-BD66-82A85F0CF695&wocid=0x1&eid=/._._._._._._.1._.2._._.1._._.0._.1._._._.1.commit&event=commit&value=test123456
POST /handle?wosid=52B8CAE2-6481-4589-BD66-82A85F0CF695&wocid=0x1&eid=/._._._._._._.1._.2._._.1._._.0._.1._._._.2._._.1&event=click

@shial4
Copy link
Contributor Author

shial4 commented Jan 14, 2020

I think the problem might be inside
ObservedObject.swift line 94
Nothing happens after.
context.invalidateComponentWithID(elementID)
Is there anything missing? @helje5 Can you help me with this?
Should context somehow force with to redraw or something like that?

Logs:

POST /handle?wosid=41B97951-521A-4647-B8B4-ECCB49D136FF&wocid=0x1&eid=/._._._._._._.1._.2._._.1._._.0._.1._._._.2._._.1&event=click
RP: not taking values ..
RP: invoke: /._._._._._._.1._.2._._.1._._.0._.1._._._.2._._.1 ..
ENTER: MainView / parent: -
ENTER: LoginView /._._ parent: MainView
ENTER: SigninView /._._._._._._.1._.2._._.1._._.0._.1 parent: LoginView
LEAVE: SigninView /._._._._._._.1._.2._._.1._._.0._.1
LEAVE: LoginView /._._
LEAVE: MainView /
RP: did invoke.
RP: no invalid components, return
INVALIDATE: /
INVALIDATE: / invalid: /
INVALIDATE: /._._
  INVALIDATE: /._._ parent already invalid: /
INVALIDATE: /._._._._._._.1._.2._._.1._._.0._.0
  INVALIDATE: /._._._._._._.1._.2._._.1._._.0._.0 parent already invalid: /
INVALIDATE: /._._._._._._.1._.2._._.1._._.0._.1
  INVALIDATE: /._._._._._._.1._.2._._.1._._.0._.1 parent already invalid: /

It stops here.
Where correct logs would look like this:

OST /handle?wosid=41B97951-521A-4647-B8B4-ECCB49D136FF&wocid=0x1&eid=/._._._._._._.1._.2._._.1._._.0._.1._._._.0.change&event=commit&value=t
RP: taking value: t ..
ENTER: MainView / parent: -
ENTER: LoginView /._._ parent: MainView
ENTER: SigninView /._._._._._._.1._.2._._.1._._.0._.1 parent: LoginView
INVALIDATE: /._._._._._._.1._.2._._.1._._.0._.1
INVALIDATE: /._._._._._._.1._.2._._.1._._.0._.1 invalid: /._._._._._._.1._.2._._.1._._.0._.1
LEAVE: SigninView /._._._._._._.1._.2._._.1._._.0._.1
LEAVE: LoginView /._._
LEAVE: MainView /
RP: did take value.
RP: invoke: /._._._._._._.1._.2._._.1._._.0._.1._._._.0.change ..
ENTER: MainView / parent: -
ENTER: LoginView /._._ parent: MainView
ENTER: SigninView /._._._._._._.1._.2._._.1._._.0._.1 parent: LoginView
LEAVE: SigninView /._._._._._._.1._.2._._.1._._.0._.1
LEAVE: LoginView /._._
LEAVE: MainView /
RP: did invoke.
RP: #1 invalid components, generate changes:

@helje5
Copy link
Member

helje5 commented Jan 14, 2020

I'm going to have a look, but I can't say when yet. Have to work on non-toy projects as well :-)

@shial4
Copy link
Contributor Author

shial4 commented Jan 14, 2020

From what I think is happening (If you can confirm). Button click event=click which is POST is not modifying values of virtual DOM. It is executing async operation. Server login request from within the application. Request this returns response either success or failure. Modifying EnvironmentObject -> ObservedObject it does invalidate Layout. Which we can see in the logs. However, the line of code I've pointed in my comment above is not pushing those changes to the client (browser). There's no pulling, watchers or so ever which would reload it. Am I correct?

If yes, what would be possible solution in your opinion. You are the author of this project, you know it best. It's hard to onboard myself without knowledge transfer or tests in the project.

My apologies for this spam and bothering you. I would like this project to be something more then a toy project. That's why I've decided to get involved. Thanks 😊

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

2 participants