ReSwift: ReSwift crashes on device (but not simulator)
Help! I have been chugging along using ReSwift (on 3.0, Swift3, XCode 8.3) and now for some reason upon initialization ReSwift is crashing (when I run it on my 10.3.1/iPhone7+ thru XCode). I hate these esoteric errors and am hoping beyond hope that someone has experienced anything remotely similar.
AppDelegate has the usual declaration
let store = Store<State>(reducer: AppReducer(), state: nil)
Then my first ViewController subscribes:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
store.subscribe(self) { state in
state.authenticationState
}
}
ReSwift goes through the initialization process until it gets to my AppReducer, and BAM !
Thanks everyone,
–Bill
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 45 (11 by maintainers)
Hi Guys, finally I have a clue related with this issue.
The problem occurs after memory corrupted in 32 bit devices when the struct size (substate struct size) is > ~2100 bytes.
I’ve split my substates into smaller structs, so each structs byte size in main reducer < 2000 bytes. i.e inspecting using this command in main reducer.
So far with this approach, the app working fine.
I’ve created a bug in the swift JIRA. https://bugs.swift.org/browse/SR-11093
What should be the approach to deal with this in ReSwift? I’m currently using a guard, so that the
appReducerdoes not create a ton of temporary AppState objects. However, every time I create a new substate I have to add it in two spots.I can deal with this for now, but I think the documentation should be updated with an approach that is less gross. Instead of a struct could the AppState be a dictionary, so we gain that copy-on-write benefit?