Hi there,
I have regularly a really weird and random error in Xcode when running on the simulator, on iOs only :
I had this bug since RN v0.21 and still have it on RN v0.26.
It's really hard to reproduce, but I think it has to do with the asyncStorage somehow because commenting my code (it seems especially AsyncStorage.multiGet) interacting with the asyncStorage, relaunching the app and uncommenting then reloading the JS package makes the bug go away...
The stack trace in Xcode is :
2016-06-07 10:07:56.514 RNOSDStarter[33977:6342335] Communications error: <OS_xpc_error: <error: 0x106ff7b40> { count = 1, contents =
"XPCErrorDescription" => <string: 0x106ff7ef0> { length = 22, contents = "Connection interrupted" }
}>
2016-06-07 10:11:39.995 MyProject[33977:6335407] *** Assertion failure in __33-[RCTUIManager setFrame:forView:]_block_invoke(), /Users/adrien/Projects/myProject/node_modules/react-native/React/Modules/RCTUIManager.m:398
2016-06-07 10:11:40.037 MyProject[33977:6335407] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not locate shadow view with tag #8'
*** First throw call stack:
(
0 CoreFoundation 0x000000010382ad85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001029f6deb objc_exception_throw + 48
2 CoreFoundation 0x000000010382abea +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000102640e1e -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 169
4 RNOSDStarter 0x000000010226b342 __33-[RCTUIManager setFrame:forView:]_block_invoke + 386
5 libdispatch.dylib 0x0000000106cb7d9d _dispatch_call_block_and_release + 12
6 libdispatch.dylib 0x0000000106cd83eb _dispatch_client_callout + 8
7 libdispatch.dylib 0x0000000106cbe82c _dispatch_queue_drain + 2215
8 libdispatch.dylib 0x0000000106cbdd4d _dispatch_queue_invoke + 601
9 libdispatch.dylib 0x0000000106cc0996 _dispatch_root_queue_drain + 1420
10 libdispatch.dylib 0x0000000106cc0405 _dispatch_worker_thread3 + 111
11 libsystem_pthread.dylib 0x00000001070154de _pthread_wqthread + 1129
12 libsystem_pthread.dylib 0x0000000107013341 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Any help or lead on how to debug this would be awesome!
Other info :
@facebook-github-bot label iOS
@adrienthiery i had the same problem calling AsyncStorage.getItem in a componentDidMount method, and what was causing the problem had to do with setting the state of the component on the callback of AsyncStorage.getItem, i guess the scope was not set at that point in order to call this.setState({myProp: true}); . But just so you know this only happens on "debug" build type on the device, it will NOT happen on Simulator and it will NOT happen on "release" type build because for release assertions are canceled so kinda makes sense.
Here is a snapshot on how my code looked like when it failed, removing this.setState(..) solved it. I wasn't needing it anyway.
https://www.dropbox.com/s/46m8l4v6vzcqk7d/Screenshot%202016-06-10%2022.29.58.png?dl=0
Mmmh, okay I will look if I have components directly hooked to the callback.
I indeed saw that it wasn't happening on production builds but it still is sometimes a pain in the butt while developing.
Thanks for the tip, I'll try to fix it and if I do, will update this thread :)
I'm experiencing the same problem. I'm keeping some session data in AsyncStorage, so on logout button press I'm destroying them, then I go to back launcher screen and check for their existence. In almost 100% of the cases it results in NSInternalInconsistencyException.
I'm using RN 0.24.1, will try later on newer RN, too.
After upgrading to RN 0.27.2 I'm still experiencing the issue, with 100% reproduction. I'll try to distill some sample app to showcase this.
I have the same issue, related to setState() as mentioned above.
In my cases, it seems that while fetching from AsyncStorage if view appear and disappear too quickly this error seems occurs. If I do below it works fine for me.
setTimeout(() => {
store.dispatch(toggleLoading(false));
}, 500);
return;
Event I postpone dispatch using setTimeout, 0 magic doesn't help. So weird, but it is working for me. I tried this because error indicates something about views, not storage. Could not locate shadow view with tag
@alma-socar Why not using InteractionManager.runAfterInteractions(()> { ... })? why do you need to depend on an arbitrary time in order to avoid it?
@alextkd I just didn't know it. Thanks!
[EDITED]
Actually same thing happens after I applying InteractionManager.runAfterInteractions as well.
Since it's been a while and we don't have a clear repro, I'm going to close this issue. Please feel free to open a new one, ideally with sample code that makes this bug easy to reproduce.
If anybody still has this problem :
The solution I found was to stop using AsyncStorage altogether, I use RealmDB : It is faster, easier and way more powerful.
I, on the other hand, only had to correctly use AsyncStorage's methods promises.
This results in the above mentioned error:
// 1 - Showing a Dialog component
showModal();
// 2 - Incorrectly handling AsyncStorage and ignoring promise
AsyncStorage.setItem(APP_STORAGE_KEY, JSON.stringify(newState));
// 3 - Hiding the Dialog component
hideModal();
This works :-)
// 1 - Showing a Dialog component
showModal();
// 2 - Correctly handle AsyncStorage's promise
AsyncStorage.setItem(APP_STORAGE_KEY, JSON.stringify(newState))
.then(() => hideModal())
.catch(e => {
hideModal();
showAlert(e);
});
For me this was about presenting and hiding a view too quickly
I'm having this issue.
It has nothing to do with the code. Don't change your code.
My fellas in the company doesn't have any problem with the same xcode, simulator and macos version. Sourcecode is also the very same.
I'd say it's a problem of Apple.
It seems you have replaced ios Directory with different ios directory from Root of react-native project , so you need to new instance of your project and configure ios set up .
Most helpful comment
In my cases, it seems that while fetching from
AsyncStorageif view appear and disappear too quickly this error seems occurs. If I do below it works fine for me.Event I postpone dispatch using
setTimeout, 0magic doesn't help. So weird, but it is working for me. I tried this because error indicates something about views, not storage.Could not locate shadow view with tag