如何修复facebook::react::Value::toJSONString



问题

我在生产中收到了一份令人讨厌的崩溃报告,我无法解决,但我认为这与github问题有关。

问题是,看起来崩溃是随机出现的,而不是在某个动作之后。

我找到了下一行的来源,我认为这与崩溃有关,但我不确定。

2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #11 pc 0005e669  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so (JSValueCreateJSONString+72)

更新:
通过使用addr2line,我成功地跟踪了如下堆栈:

ReactCommon/jschelpers/Value.cpp#64

2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #11 pc 0005e669  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so (JSValueCreateJSONString+72)

ReactCommon/cxrreact/MethodCall.cpp#21

2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #12 pc 0003b3b9  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZNK8facebook5react5Value12toJSONStringEj+20)

ReactCommon/cxrreact/Instance.cpp#69

2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #13 pc 00033c3b  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZN8facebook5react11JSCExecutor19flushQueueImmediateEONS0_5ValueE+26)

ReactCommon/cxrreact/Instance.cpp#125

2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #14 pc 00033d6f  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZN8facebook5react11JSCExecutor25nativeFlushQueueImmediateEjPKPK13OpaqueJSValue+86)

更新:
我创建了一个小吃演示来重现崩溃
通过在每次"012345678".repeat(1024*1024)时存储此字符串,您可以重现错误(对我来说,当我添加第三个或第四个时,它会崩溃)

小吃演示

问题:

如果你有任何建议,当崩溃发生时,我如何从adb-logcat或其他软件中获得更多信息,请告诉我。

此外,如果你以前也有类似的错误,请告诉我你是如何解决的,以及崩溃的原因是什么。

碰撞报告:

2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #00 pc 003b3ac0  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #01 pc 003b1601  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #02 pc 00364861  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #03 pc 0037134d  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #04 pc 003706c1  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #05 pc 00370e55  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #06 pc 00290f71  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #07 pc 00291fbd  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #08 pc 002913ab  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #09 pc 002908d9  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #10 pc 0029402f  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #11 pc 0005e669  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so (JSValueCreateJSONString+72)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #12 pc 0003b3b9  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZNK8facebook5react5Value12toJSONStringEj+20)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #13 pc 00033c3b  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZN8facebook5react11JSCExecutor19flushQueueImmediateEONS0_5ValueE+26)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #14 pc 00033d6f  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so (_ZN8facebook5react11JSCExecutor25nativeFlushQueueImmediateEjPKPK13OpaqueJSValue+86)
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #15 pc 00034ab1  /data/app/com.xyzor.timer-1/lib/arm/libreactnativejni.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #16 pc 0004eda9  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #17 pc 0012fa9b  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:50.203 10137-10137/? A/DEBUG:     #18 pc 0012f60d  /data/app/com.xyzor.timer-1/lib/arm/libjsc.so
2019-02-07 14:22:52.073 1257-10138/? W/ActivityManager:   Force finishing activity com.xyzor.timer/host.exp.exponent.experience.ShellAppActivity
2019-02-07 14:22:52.140 1257-1272/? D/ViewRootImpl@2042207[timer]: ThreadedRenderer.create() translucent=true
2019-02-07 14:22:52.142 1257-1272/? D/WindowManager: openInputChannel mInputChannel: a585ad2 Application Error: com.xyzor.timer (server)
2019-02-07 14:22:52.144 1257-1272/? D/ViewRootImpl@2042207[timer]: setView = DecorView@83d521e[timer] touchMode=true
2019-02-07 14:22:52.162 7102-10144/? W/PkgUtils: p: com.xyzor.timer, u:0
2019-02-07 14:22:52.167 1257-1272/? D/ViewRootImpl@2042207[timer]: dispatchAttachedToWindow
2019-02-07 14:22:52.194 1257-1272/? D/ViewRootImpl@2042207[timer]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[256,816][1280,1279] result=0x27 surface={isValid=true 547307523072} surfaceGenerationChanged=true
2019-02-07 14:22:52.194 1257-1272/? D/ViewRootImpl@2042207[timer]: mHardwareRenderer.initialize() mSurface={isValid=true 547307523072} hwInitialized=true
2019-02-07 14:22:52.197 1257-1272/? D/ViewRootImpl@2042207[timer]: MSG_WINDOW_FOCUS_CHANGED 1
2019-02-07 14:22:52.197 1257-1272/? D/ViewRootImpl@2042207[timer]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 547307523072}
2019-02-07 14:22:52.209 7187-7204/? W/PkgUtils: p: com.xyzor.timer, u:0
2019-02-07 14:22:52.230 1257-1272/? D/WindowManager: finishDrawingWindow: Window{a585ad2d0 u0 Application Error: com.xyzor.timer} mDrawState=DRAW_PENDING
2019-02-07 14:22:52.231 1257-1272/? D/ViewRootImpl@2042207[timer]: MSG_RESIZED_REPORT: frame=Rect(256, 816 - 1280, 1279) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
2019-02-07 14:22:52.236 1257-1272/? D/WindowManager: finishDrawingWindow: Window{a585ad2d0 u0 Application Error: com.xyzor.timer} mDrawState=HAS_DRAWN
2019-02-07 14:22:52.448 1257-1385/? I/WindowManager: WIN DEATH: Window{2a8ca6fd0 u0 com.xyzor.timer/host.exp.exponent.experience.ShellAppActivity}
2019-02-07 14:22:52.449 1257-1385/? D/WindowManager: disposeInputChannel mInputChannel: 2a8ca6f com.xyzor.timer/host.exp.exponent.experience.ShellAppActivity (server)
2019-02-07 14:22:52.449 1257-2210/? I/ActivityManager: Process com.xyzor.timer (pid 9982) has died(864,760)

一般信息:

  • 我将Expo与Expo SDK 31一起使用,并使用react native 0.57
  • 我可以通过adb-logcat登录该应用程序
  • 我对原生android开发没有太多经验

问题是我向JSON.stringify()传递了一个对象,这个对象太大了,应用程序没有足够的内存来存储这个字符串。

  1. 解决方案(理想)

切换到流式传输方法。类似JSONStream

对我来说,这是不可能的,因为我正在使用Expo(可能甚至在RN中都做不到)

  1. 将数据拆分为单独的文件

因为问题的根源是不能将太大的对象/字符串传递给JSON。[Stringfy,parse],我只是简单地将数据拆分为不同的文件。

幸运的是,我使用了带有自定义存储引擎的redux-persistent,所以我能够修改必要的方法来处理这些数据。

相关内容

  • 没有找到相关文章

最新更新