Crashes when using Redux-Persist with React Native on iOS device - ios

I've been trying to use redux-persist in a React Native app that I'm building, but whenever I do, I get random crashes when running on an iOS device. This problem does not occur when running on the simulator. It happens on versions 4 and 5 of redux-persist.
According to sentry.io, the error is:
EXC_BREAKPOINT main
fatalException 6, Code 2390738480, Subcode 8
I've tested this on all released versions of iOS 11. Sometimes it seems that the error has disappeared for a few days of normal usage, but then it will return, often repeatedly. This behaviour suggests that the crash only occurs when the store reaches a certain state, or if it becomes too large. As far as I can tell, though, this is not the case - apparently Async Storage does not have a size limit on iOS (unlike Android).
The sentry.io stack trace doesn't seem to provide any clues, but here it is anyway:
JavaScriptCore 0x18e7fc630 bmalloc::Heap::allocateLarge(std::__1::lock_guard&, unsigned long, unsigned long)
JavaScriptCore 0x18e7f9ea4 bmalloc::Allocator::allocateLarge(unsigned long)
JavaScriptCore 0x18deb8a04 WTF::fastMalloc(unsigned long)
JavaScriptCore 0x18dec9d50 WTF::StringImpl::createUninitialized(unsigned int, unsigned short*&)
JavaScriptCore 0x18dec9bf8 WTF::StringBuilder::allocateBufferUpConvert(unsigned char const*, unsigned int)
JavaScriptCore 0x18e7e76f0 WTF::StringBuilder::appendQuotedJSONString(WTF::String const&)
JavaScriptCore 0x18e55a2cc JSC::Stringifier::appendStringifiedValue(WTF::StringBuilder&, JSC::JSValue, JSC::Stringifier::Holder const&, JSC::PropertyNameForFunctionCall const&)
JavaScriptCore 0x18e55b354 JSC::Stringifier::Holder::appendNextProperty(JSC::Stringifier&, WTF::StringBuilder&)
JavaScriptCore 0x18e55a5d4 JSC::Stringifier::appendStringifiedValue(WTF::StringBuilder&, JSC::JSValue, JSC::Stringifier::Holder const&, JSC::PropertyNameForFunctionCall const&)
JavaScriptCore 0x18e5594e0 JSC::Stringifier::stringify(JSC::Handle)
JavaScriptCore 0x18e55d804 JSC::JSONProtoFuncStringify(JSC::ExecState*)
JavaScriptCore 0x18e5f34c8 llint_entry
JavaScriptCore 0x18e5f2a94 llint_entry
JavaScriptCore 0x18e5f2a94 llint_entry
JavaScriptCore 0x18e5f2a94 llint_entry
JavaScriptCore 0x18e5f2a30 llint_entry
JavaScriptCore 0x18e5f2ee0 llint_entry
JavaScriptCore 0x18e5f2a30 llint_entry
JavaScriptCore 0x18e5f2a94 llint_entry
JavaScriptCore 0x18e5f2a30 llint_entry
JavaScriptCore 0x18e5ebf50 llintPCRangeStart
JavaScriptCore 0x18e4d1b94 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*)
JavaScriptCore 0x18def71b8 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
JavaScriptCore 0x18e506c3c JSC::boundThisNoArgsFunctionCall(JSC::ExecState*)
JavaScriptCore 0x18e5ec098 vmEntryToNative
JavaScriptCore 0x18def7200 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
JavaScriptCore 0x18e14a1fc JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
JavaScriptCore 0x18def6f68 JSObjectCallAsFunction
rizzle 0x1013eca4c facebook::react::Object::callAsFunction(OpaqueJSValue*, int, OpaqueJSValue const* const*) const
rizzle 0x10140c76c facebook::react::JSCExecutor::callFunction(std::__1::basic_string, std::__1::allocator > const&, std::__1::basic_string, std::__1::allocator > const&, folly::dynamic const&)
at setJSResponder(node_modules/react-native-sentry/lib/NativeClient.js:155:29)
at onChange(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:3241:23)
at setResponderAndExtractTransfer(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:3354:140)
at extractEvents(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:3463:85)
at extractEvents(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:2971:54)
at fn(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:3201:47)
at batchedUpdates(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:2448:20)
at batchedUpdates(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:198:16)
at _receiveRootNodeIDEvent(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:3221:32)
at apply(node_modules/react-native/Libraries/Renderer/ReactNativeFiber-prod.js:3234:37)
at fn(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:299:42)
at __guard(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:262:7)
at value(node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:110:10)
rizzle 0x10140bb00 std::__1::function::operator()(OpaqueJSContext*) const
rizzle 0x10139a110 facebook::react::tryAndReturnError(std::__1::function const&)
rizzle 0x1013923a8 facebook::react::RCTMessageThread::tryFunc(std::__1::function const&)
CoreFoundation 0x18756016c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
CoreFoundation 0x18755fa3c __CFRunLoopDoBlocks
CoreFoundation 0x18755dca4 __CFRunLoopRun
CoreFoundation 0x18747e2d8 CFRunLoopRunSpecific
rizzle 0x101374c48 +[RCTCxxBridge runRunLoop]
Foundation 0x187fa7860 __NSThread__start__
libsystem_pthread 0x1871e432c _pthread_body
libsystem_pthread 0x1871e41f8 _pthread_start
I've been trying to get to the bottom of this for over 3 months now, and have been trying out alternative libraries, but I would really like to be able to use redux-persist.

I've encountered the exact same error and stack trace with redux-persist, which seemed to be caused when the size of data in one of my reducers was too large for some aspect of the storage engine to handle.
In my case, the json that was trying to be persisted was 520000000 characters in size!
In the end, the best solution I found was to split that persisted reducer into smaller reducers, which I then combined in my app, so that I could handle it as one from my application code.
I also experimented with different storage engines to find the one that handled that amount of data the best, finally settling on a redux-persist-realm, though we did patch it to fix some errors we were getting.
To split the reducer I used the first character of each items uuid, so that I would get 16 reasonable even sized sub-sets.
First I created a reducer for each of the potential first characters of the uuid
const store = createStore(
{
... other reducers
recordsDataA: createReducer('A'),
recordsDataB: createReducer('B'),
recordsDataC: createReducer('C'),
recordsDataD: createReducer('D'),
recordsDataE: createReducer('E'),
...
},
applyMiddleware(...middlewares),
enhancer
)
export const createReducer = key => combineReducers({
records: recordsReducer(key),
})
const recordsReducer = batch => (state = [], action) => {
switch (action.type) {
case REQUEST_RECORDS_SUCCESS:
return action.records.filter(record => record.id[0].toUpperCase() === batch)
... other actions
default:
return state
}
}
Then in my selector, using reselect, I combined the individual reducers back into a single array, so that it can easily be used from other selectors. i.e -
export const makeGetAllRecords = () =>
createSelector(
[
state => state.recordsDataA.records,
state => state.recordsDataB.records,
state => state.recordsDataC.records,
state => state.recordsDataD.records,
state => state.recordsDataE.records,
state => state.recordsDataF.records,
...
],
(...allBatches) => [].concat(...allBatches)
)
export const getRecordById = (state: Array<Record>, recordId: string) =>
makeGetAllRecords()(state).find(record => record.id === recordId) || null
I'm sure there is plenty that can be done to neaten and optimise that code, but its working well for as in production as is.

Related

iOS crash in executing JS by JavascriptCore

My iOS app suffers a crash that hard to be reproduced. Here's crash stack I can provide.
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000 (sometimes nonzero, like 0x1170000000007db7)
Crashed: com.apple.main-thread
0 JavaScriptCore 0xe3dc1c JSC::objectConstructorAssign(JSC::JSGlobalObject*, JSC::CallFrame*) + 656
1 JavaScriptCore 0x2b80a0 llint_function_for_construct_arity_checkTagGateAfter + 160236
2 JavaScriptCore 0x2b80a0 llint_function_for_construct_arity_checkTagGateAfter + 160236
3 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
4 JavaScriptCore 0x2b4a48 llint_function_for_construct_arity_checkTagGateAfter + 146324
5 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
6 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
7 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
8 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
9 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
10 JavaScriptCore 0x2b4a48 llint_function_for_construct_arity_checkTagGateAfter + 146324
11 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
12 JavaScriptCore 0x2b4a48 llint_function_for_construct_arity_checkTagGateAfter + 146324
13 JavaScriptCore 0x2b4990 llint_function_for_construct_arity_checkTagGateAfter + 146140
14 JavaScriptCore 0x2b5f90 llint_function_for_construct_arity_checkTagGateAfter + 151772
15 JavaScriptCore 0x28a980 vmEntryToJavaScriptGateAfter + 6
16 JavaScriptCore 0x9fdfe8 JSC::Interpreter::executeCall(JSC::JSGlobalObject*, JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 532
17 JavaScriptCore 0xc74cb0 JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 184
18 JavaScriptCore 0x36ecfc JSObjectCallAsFunction + 572
19 ... (skips app stack)
For more information,
my app uses JSBinding to manage some JS objects.
jscontext(js global object) is not likely dealloced.
can't provide full codes. The last code snippet is JSObjectCallAsFunction(jscontext, jsobject, NULL, 0, NULL, NULL);, while jsobject refers to a js function.
I've got some information by internal test. Here're some guesses,
maybe JS objects has dealloc unexpectly.
it's not likely a multi-thread issue after reviewing my codes.
Can anyone help to identify the root cause? Any ideas will be appreciated.

AppleMetalGLRenderer Crash

I am trying to figure out what is causing this crash and so far have been unable to determine what the problem is. Any help would be greatly appreciated. This is the log from Firebase on the crash, and its happened multiple times.
Crashed: WebThread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000000048e8
0
AGXMetalA11
(Missing)
1
AppleMetalGLRenderer
GLDContextRec::setRenderTexturesAndSamplersInternal(unsigned int, unsigned int&, SetSamplerStateIMPCache*, SetTextureIMPCache*)
2
AppleMetalGLRenderer
GLDContextRec::setRenderTexturesAndSamplersInternal(unsigned int, unsigned int&, SetSamplerStateIMPCache*, SetTextureIMPCache*)
3
AppleMetalGLRenderer
GLDContextRec::setRenderSamplersAndTextures()
4
AppleMetalGLRenderer
GLDContextRec::setRenderState(unsigned int)
5
AppleMetalGLRenderer
gldRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
6
GLEngine
glDrawElements_ACC_ES2Exec
7
WebCore
WebCore::GraphicsContext3D::drawElements(unsigned int, int, unsigned int, long) + 64
8
WebCore
WebCore::WebGLRenderingContextBase::drawElements(unsigned int, int, unsigned int, long long) + 316
9
WebCore
WebCore::jsWebGLRenderingContextPrototypeFunctionDrawElements(JSC::ExecState*) + 328
10
JavaScriptCore
llint_entry + 135068
11
JavaScriptCore
llint_entry + 124496
12
JavaScriptCore
llint_entry + 124496
13
JavaScriptCore
llint_entry + 124496
14
JavaScriptCore
llint_entry + 124496
15
JavaScriptCore
llint_entry + 124664
16
JavaScriptCore
llint_entry + 124664
17
JavaScriptCore
llint_entry + 124496
18
JavaScriptCore
llint_entry + 124664
19
JavaScriptCore
llint_entry + 124496
20
JavaScriptCore
llint_entry + 124496
21
JavaScriptCore
llint_entry + 124496
22
JavaScriptCore
llint_entry + 124496
23
JavaScriptCore
llint_entry + 129852
24
JavaScriptCore
llint_entry + 124496
25
JavaScriptCore
llint_entry + 124496
26
JavaScriptCore
vmEntryToJavaScript + 248
27
JavaScriptCore
JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 408
28
JavaScriptCore
JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 196
29
WebCore
WebCore::JSExecState::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 140
30
WebCore
WebCore::JSCallbackData::invokeCallback(WebCore::JSDOMGlobalObject&, JSC::JSObject*, JSC::JSValue, JSC::MarkedArgumentBuffer&, WebCore::JSCallbackData::CallbackType, JSC::PropertyName, WTF::NakedPtr<JSC::Exception>&) + 356
31
WebCore
WebCore::JSRequestAnimationFrameCallback::handleEvent(double) + 412
32
WebCore
WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(double) + 400
33
WebCore
WebCore::Page::updateRendering() + 280
34
WebKitLegacy
LayerFlushController::flushLayers() + 52
35
WebKitLegacy
WebViewLayerFlushScheduler::layerFlushCallback() + 56
36
CoreFoundation
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
37
CoreFoundation
__CFRunLoopDoObservers + 416
38
CoreFoundation
CFRunLoopRunSpecific + 496
39
WebCore
RunWebThread(void*) + 612
40
libsystem_pthread.dylib
_pthread_start + 156
41
libsystem_pthread.dylib
thread_start + 8
I am not sure why its reporting java because we are not using java in this app; I can only assume Apple has something running in the background. Also, We are not using AppleMetalGLRenderer specifically so again I'm assuming that Apple has it on by default?
Any help would be appreciated.

UIWebView WTFCrash CSSParser::addNamespace

We are facing the following crash in our iOS Cordova based app:
Crashed: WebThread
0 JavaScriptCore 0x187a3b22c WTFCrash + 72
1 JavaScriptCore 0x187a3b224 WTFCrash + 64
2 WebCore 0x187d6c4fc WebCore::CSSParser::addNamespace(WTF::AtomicString const&, WTF::AtomicString const&) + 186
3 WebCore 0x188a6ecac WebCore::TextResourceDecoder::decodeAndFlush(char const*, unsigned long) + 192
4 WebCore 0x187cb5c9c WebCore::CachedScript::script() + 72
5 JavaScriptCore 0x187a21f20 std::__1::unique_ptr<JSC::FunctionNode, std::__1::default_delete<JSC::FunctionNode> > JSC::parse<JSC::FunctionNode>(JSC::VM*, JSC::SourceCode const&, JSC::FunctionParameters*, JSC::Identifier const&, JSC::JSParserBuiltinMode, JSC::JSParserStrictMode, JSC::JSParserCodeType, JSC::ParserError&, JSC::JSTextPosition*, JSC::ConstructorKind, JSC::ThisTDZMode) + 88
6 JavaScriptCore 0x187a21550 JSC::UnlinkedFunctionExecutable::codeBlockFor(JSC::VM&, JSC::SourceCode const&, JSC::CodeSpecializationKind, JSC::DebuggerMode, JSC::ProfilerMode, JSC::ParserError&) + 156
7 JavaScriptCore 0x1877a3440 JSC::ScriptExecutable::newCodeBlockFor(JSC::CodeSpecializationKind, JSC::JSFunction*, JSC::JSScope*, JSC::JSObject*&) + 508
8 JavaScriptCore 0x1877a3a70 JSC::ScriptExecutable::prepareForExecutionImpl(JSC::ExecState*, JSC::JSFunction*, JSC::JSScope*, JSC::CodeSpecializationKind) + 104
9 JavaScriptCore 0x1875229b0 JSC::LLInt::setUpCall(JSC::ExecState*, JSC::Instruction*, JSC::CodeSpecializationKind, JSC::JSValue, JSC::LLIntCallLinkInfo*) + 164
10 JavaScriptCore 0x187961e58 llint_entry + 23912
11 JavaScriptCore 0x187961d44 llint_entry + 23636
I have tried to check the source code and found the following:
void CSSParser::addNamespace(const AtomicString& prefix, const AtomicString& uri)
{
if (!m_styleSheet || !m_allowNamespaceDeclarations)
return;
m_allowImportRules = false;
m_styleSheet->parserAddNamespace(prefix, uri);
if (prefix.isEmpty() && !uri.isNull())
m_defaultNamespace = uri;
}
But I can't just figure out where could the WTFCrash be happening. Any idea?

UIWebView update in background I've got a EXC_BAD_ACCESS

I study iOS Programming alone and I want make Youtube app.
I want that I can listen when I clicked home button and I want listen many song(like a youtube playlist. but not a list I can chose song in my tablelist.)
I use youtube-ios-player-libarary
https://github.com/youtube/youtube-ios-player-helper and I solved if I press home button app continous play in background.
But I have problem now.
When I listen in background youtube video sound and than video ended don't play next video. In the app is working, but not in background. I don't get any log in Xcode like this. (I tried Zombie)
I tried to work in main thread, like this:
[self performSelectorOnMainThread:#selector(createNewWebView) withObject:nil waitUntilDone:YES];
and
dispatch_async(dispatch_get_main_queue(), ^{
[self.webView removeFromSuperview];
_webView = [self createNewWebView];
[self addSubview:self.webView];
});
But it didn't work, and now I found this device log:
Date/Time: 2016-01-18 15:42:46.46 +0900
Launch Time: 2016-01-18 15:42:33.33 +0900
OS Version: iOS 9.2 (13C75)
Report Version: 105
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x00000001
Triggered by Thread: 13
Thread 13 name: WebThread
Thread 13 Crashed:
0 libGPUSupportMercury.dylib 0x31e3d322 gpus_ReturnNotPermittedKillClient + 10
1 libGPUSupportMercury.dylib 0x31e3de12 gpusSubmitDataBuffers + 118
2 IMGSGX543RC2GLDriver 0x34bd968c 0x34bd6000 + 13964
3 WebCore 0x29260792 WebCore::GraphicsContext3D::reshape(int, int) + 434
4 WebCore 0x299371e2 WebCore::WebGLRenderingContextBase::initializeNewContext() + 502
5 WebCore 0x29936dd0 WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase(WebCore::HTMLCanvasElement*, WTF::PassRefPtr<WebCore::GraphicsContext3D>, WebCore::GraphicsContext3D::Attributes) + 484
6 WebCore 0x29931be0 WebCore::WebGLRenderingContext::WebGLRenderingContext(WebCore::HTMLCanvasElement*, WTF::PassRefPtr<WebCore::GraphicsContext3D>, WebCore::GraphicsContext3D::Attributes) + 48
7 WebCore 0x29936720 WebCore::WebGLRenderingContextBase::create(WebCore::HTMLCanvasElement*, WebCore::WebGLContextAttributes*, WTF::String const&) + 772
8 WebCore 0x28fcfbca WebCore::HTMLCanvasElement::getContext(WTF::String const&, WebCore::CanvasContextAttributes*) + 250
9 WebCore 0x28fcfa46 WebCore::JSHTMLCanvasElement::getContext(JSC::ExecState*) + 154
10 WebCore 0x28fcf988 WebCore::jsHTMLCanvasElementPrototypeFunctionGetContext(JSC::ExecState*) + 88
11 JavaScriptCore 0x28bad71e llint_entry + 21374
12 JavaScriptCore 0x28bad338 llint_entry + 20376
13 JavaScriptCore 0x28bad338 llint_entry + 20376
14 JavaScriptCore 0x28bad338 llint_entry + 20376
15 JavaScriptCore 0x28bad338 llint_entry + 20376
16 JavaScriptCore 0x28ba8190 vmEntryToJavaScript + 336
17 JavaScriptCore 0x28b016da JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 102
18 JavaScriptCore 0x288eaa18 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 344
19 JavaScriptCore 0x288ea8bc JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 60
20 JavaScriptCore 0x2897d780 JSC::boundFunctionCall(JSC::ExecState*) + 324
21 JavaScriptCore 0x28bad71e llint_entry + 21374
22 JavaScriptCore 0x28bad4ba llint_entry + 20762
23 JavaScriptCore 0x28bad338 llint_entry + 20376
24 JavaScriptCore 0x28bad338 llint_entry + 20376
25 JavaScriptCore 0x28ba8190 vmEntryToJavaScript + 336
26 JavaScriptCore 0x28b016da JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 102
27 JavaScriptCore 0x288eaa18 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 344
28 JavaScriptCore 0x288ea8bc JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 60
29 JavaScriptCore 0x2897d780 JSC::boundFunctionCall(JSC::ExecState*) + 324
30 JavaScriptCore 0x28bad71e llint_entry + 21374
31 JavaScriptCore 0x28bad338 llint_entry + 20376
32 JavaScriptCore 0x28ba8190 vmEntryToJavaScript + 336
33 JavaScriptCore 0x28b016da JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 102
34 JavaScriptCore 0x288eaa18 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 344
35 JavaScriptCore 0x288ea8bc JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 60
36 JavaScriptCore 0x2897d780 JSC::boundFunctionCall(JSC::ExecState*) + 324`enter code here`
37 JavaScriptCore 0x28bad71e llint_entry + 21374
38 JavaScriptCore 0x28bad338 llint_entry + 20376
39 JavaScriptCore 0x28ba8190 vmEntryToJavaScript + 336
40 JavaScriptCore 0x28b016da JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 102
41 JavaScriptCore 0x288eaa18 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 344
42 JavaScriptCore 0x289c6f38 JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 64
43 WebCore 0x28f95df2 WebCore::JSEventListener::handleEvent(WebCore::ScriptExecutionContext*, WebCore::Event*) + 490
44 WebCore 0x291e17d8 WebCore::EventTarget::fireEventListeners(WebCore::Event*, WebCore::EventTargetData*, WTF::Vector<WebCore::RegisteredEventListener, 1ul, WTF::CrashOnOverflow, 16ul>&) + 532
45 WebCore 0x28edb96c WebCore::EventTarget::fireEventListeners(WebCore::Event*) + 232
46 WebCore 0x28fd60a0 WebCore::EventTarget::dispatchEvent(WTF::PassRefPtr<WebCore::Event>) + 64
47 WebCore 0x291aebe6 WebCore::DOMWindow::dispatchMessageEventWithOriginCheck(WebCore::SecurityOrigin*, WTF::PassRefPtr<WebCore::Event>, WTF::PassRefPtr<Inspector::ScriptCallStack>) + 66
48 WebCore 0x291aeb62 WebCore::DOMWindow::postMessageTimerFired(WebCore::PostMessageTimer&) + 98
49 WebCore 0x291b212e WebCore::PostMessageTimer::fired() + 14
50 WebCore 0x28e89898 WebCore::ThreadTimers::sharedTimerFiredInternal() + 136
51 WebCore 0x28e897ec WebCore::timerFired(__CFRunLoopTimer*, void*) + 28
52 CoreFoundation 0x25b919e6 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 14
53 CoreFoundation 0x25b91618 __CFRunLoopDoTimer + 936
54 CoreFoundation 0x25b8f464 __CFRunLoopRun + 1500
55 CoreFoundation 0x25ae1bb8 CFRunLoopRunSpecific + 516
56 CoreFoundation 0x25ae19ac CFRunLoopRunInMode + 108
57 WebCore 0x28ecfcbe RunWebThread(void*) + 422
58 libsystem_pthread.dylib 0x25906c7e _pthread_body + 138
59 libsystem_pthread.dylib 0x25906bf2 _pthread_start + 110
60 libsystem_pthread.dylib 0x25904a08 thread_start + 8
————————————
16.01.19
tried
dispatch_async(dispatch_get_main_queue(), ^{
if (self.webView != nil) {
self.webView removeFromSuperview];
_webView = [self createNewWebView];
[self addSubview:self.webView];
}
});
and
if (self.webView == nil) {
self.webView removeFromSuperview];
_webView = [self createNewWebView];
[self addSubview:self.webView];
}
but It didn’t work.
What can I change or add code ?
Please help me guys..
Its crashing because of open GL in the background.
You will need to disable open GL if the app is in background.
Here is the Code to do that :
typedef void (*CallFuc)(id, SEL, BOOL);
typedef BOOL (*GetFuc)(id, SEL);
-(BOOL)webView:(UIWebView*)view enableGL:(BOOL)bEnable
{
BOOL bRet = NO;
do
{
Ivar internalVar = class_getInstanceVariable([view class], "_internal");
if (!internalVar)
{
NSLog(#"enable GL _internal invalid!");
break;
}
UIWebViewInternal* internalObj = object_getIvar(view, internalVar);
Ivar browserVar = class_getInstanceVariable(object_getClass(internalObj), "browserView");
if (!browserVar)
{
NSLog(#"enable GL browserView invalid!");
break;
}
id webbrowser = object_getIvar(internalObj, browserVar);
Ivar webViewVar = class_getInstanceVariable(object_getClass(webbrowser), "_webView");
if (!webViewVar)
{
NSLog(#"enable GL _webView invalid!");
break;
}
id webView = object_getIvar(webbrowser, webViewVar);
if (!webView)
{
NSLog(#"enable GL webView obj nil!");
}
if(object_getClass(webView) != NSClassFromString(#"WebView"))
{
NSLog(#"enable GL webView not WebView!");
break;
}
SEL selector = NSSelectorFromString(#"_setWebGLEnabled:");
IMP impSet = [webView methodForSelector:selector];
CallFuc func = (CallFuc)impSet;
func(webView, selector, bEnable);
SEL selectorGet = NSSelectorFromString(#"_webGLEnabled");
IMP impGet = [webView methodForSelector:selectorGet];
GetFuc funcGet = (GetFuc)impGet;
BOOL val = funcGet(webView, selector);
bRet = (val == bEnable);
}while(NO);
return bRet;
}
Call [self webView:self.yourWebView enableGL:NO] when app is in background.

UIWebView crash: OpenGLES - glTexImage2D

I have a UIWebView based iOS application which has recently started crashing quite a lot. I strongly believe the crash is caused by something that has changed in the web content (worst-case, but maybe most likely, scenario is it's a 3rd party banner ad), since the crash reports started to come in for all version of my iOS app on the same day, suddenly going from 0 to several hundred crashes.
Here is the crash stack trace on iOS9:
Thread : Crashed: WebThread
0 libmetal_timestamp.dylib 0x18cf2df08 (Missing)
1 libmetal_timestamp.dylib 0x18cf2eec4 (Missing)
2 libmetal_timestamp.dylib 0x18cf335ac (Missing)
3 MobileCoreServices 0x185c941a8 (Missing)
4 MobileCoreServices 0x185bf3428 (Missing)
5 OpenGLES 0x185ccea9c glTexImage2D + 108
6 WebCore 0x1946e3da8 WebCore::GraphicsContext3D::texImage2D(unsigned int, int, unsigned int, int, int, int, unsigned int, unsigned int, void const*) + 60
7 WebCore 0x194ffb37c WebCore::WebGLRenderingContextBase::texImage2DBase(unsigned int, int, unsigned int, int, int, int, unsigned int, unsigned int, void const*, int&) + 160
8 WebCore 0x194ffbb84 WebCore::WebGLRenderingContextBase::texImage2D(unsigned int, int, unsigned int, int, int, int, unsigned int, unsigned int, JSC::ArrayBufferView*, int&) + 784
9 WebCore 0x194b80ba4 WebCore::jsWebGLRenderingContextBasePrototypeFunctionTexImage2D(JSC::ExecState*) + 2880
10 JavaScriptCore 0x1842422f0 llint_entry + 25056
11 JavaScriptCore 0x184241d10 llint_entry + 23552
12 JavaScriptCore 0x184241d10 llint_entry + 23552
13 JavaScriptCore 0x184241d10 llint_entry + 23552
14 JavaScriptCore 0x18423bef8 vmEntryToJavaScript + 312
15 JavaScriptCore 0x184168c48 JSC::JITCode::execute(JSC::VM*, JSC::ProtoCallFrame*) + 180
16 JavaScriptCore 0x183e02108 JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 400
17 JavaScriptCore 0x183eb41bc JSC::boundFunctionCall(JSC::ExecState*) + 512
18 JavaScriptCore 0x18423c080 vmEntryToNative + 320
19 JavaScriptCore 0x183e0214c JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&) + 468
20 JavaScriptCore 0x183f117dc JSC::call(JSC::ExecState*, JSC::JSValue, JSC::CallType, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&, WTF::NakedPtr<JSC::Exception>&) + 80
21 WebCore 0x1943b8ecc WebCore::JSCallbackData::invokeCallback(JSC::JSValue, JSC::MarkedArgumentBuffer&, bool*) + 580
22 WebCore 0x194a60434 WebCore::JSRequestAnimationFrameCallback::handleEvent(double) + 196
23 WebCore 0x194dd634c WebCore::ScriptedAnimationController::serviceScriptedAnimations(double) + 424
24 WebCore 0x194575c48 WebCore::DisplayRefreshMonitor::displayDidRefresh() + 428
25 QuartzCore 0x187567840 CA::Display::DisplayLinkItem::dispatch() + 40
26 QuartzCore 0x1875676f4 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 424
27 IOKit 0x183a262f8 IODispatchCalloutFromCFMessage + 372
28 CoreFoundation 0x18272e840 __CFMachPortPerform + 180
29 CoreFoundation 0x182744c7c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
30 CoreFoundation 0x1827443b4 __CFRunLoopDoSource1 + 436
31 CoreFoundation 0x18274210c __CFRunLoopRun + 1800
32 CoreFoundation 0x182670ca0 CFRunLoopRunSpecific + 384
33 WebCore 0x19425a54c RunWebThread(void*) + 456
34 libsystem_pthread.dylib 0x197c83b28 _pthread_body + 156
35 libsystem_pthread.dylib 0x197c83a8c _pthread_body + 154
36 libsystem_pthread.dylib 0x197c81028 thread_start + 4
On iOS8 it crashes with a slightly different but very very similar stack trace. The iOS8 and iOS9 crashes started at the same time so it's undoubtedly the same thing.
Given the OpenGLES references in the crash report I suspect it has something to do with DOM rendering involving the hardware. Has anyone else developed a hybrid web app and seen these crashes? Any specific CSS transforms/transitions that caused the app to crash this way?
Also, there's a reference to WebGLRenderingContextBase, does that mean that it must be caused by actual WebGL on the web page or could it still originate just form non-3D CSS styles?

Resources