如何修复facebook :: react :: Value :: toJSONString中的崩溃

问题描述 投票:5回答:1

问题

我在制作中遇到了令人讨厌的崩溃报告,我无法解决,但我认为这与这个github issue有关。

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

我追踪下一行的source,我认为必须对崩溃做些什么,但我不确定。

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/cxxreact/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/cxxreact/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/cxxreact/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)存储此字符串,您可以重现该错误。 (对我来说,当我添加第三或第四个时它会崩溃)

Snack demo

问题:

如果您有任何建议我如何从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并反应原生0.57。
  • 我可以通过adb logcat登录应用程序。
  • 我对本机android开发没有多少经验
android react-native expo sigsegv
1个回答
1
投票

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

  1. 解决方案(理想)

切换到流式传输方式。像JSONStream之类的东西

对我来说,这不是一种可能,因为我正在使用世博会(甚至可能不会在RN中完成)

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

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

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

© www.soinside.com 2019 - 2024. All rights reserved.