gpt4 book ai didi

android - 尝试在 Chrome 中调试时 React Native Android 崩溃

转载 作者:可可西里 更新时间:2023-11-01 19:07:12 25 4
gpt4 key购买 nike

我有一个适用于 iOS 的 React Native 应用程序,我正在尝试让它在 Android 上运行。我在模拟器中启动并运行了该应用程序,我想在 Chrome 中对其进行调试以找出一些问题。

当我打开应用程序内开发工具并单击“在 Chrome 中调试”选项时,应用程序崩溃了几秒钟,我收到一条警告消息,提示“不幸的是 MyApp 已停止”。然后紧接着,该应用程序返回红屏并显示“无法连接远程调试器”。

我相信我已经按照说明设置了所有内容 on this page .

有没有人见过这种问题,如果有,有办法解决吗?

谢谢!

最佳答案

Android 上同样的问题。我刚刚用 react-native init 开始了一个项目,并开始关注 Facebook 教程。

当我在不调试的情况下运行应用程序时,它运行良好。如果我启用远程调试 JS,它会在 1 分钟后崩溃(什么都不做)。

在 Samsung Galaxy S5、react-native-cli 0.2.0、react-native 0.32.1、Windows 7、Chrome 53 上进行测试。

在 Android Studio 中我发现了这个堆栈跟踪:

09-08 13:25:06.322 31080-3735/com.tutorialproject W/libc: pthread_create failed: couldn't allocate 1064960-byte stack: Out of memory
09-08 13:25:06.322 31080-3735/com.tutorialproject E/art: Throwing OutOfMemoryError "pthread_create (1040KB stack) failed: Try again"
09-08 13:25:06.332 31080-3735/com.tutorialproject E/AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher
Process: com.tutorialproject, PID: 31080
java.lang.OutOfMemoryError: pthread_create (1040KB stack) failed: Try again
at java.lang.Thread.nativeCreate(Native Method)
at java.lang.Thread.start(Thread.java:1063)
at java.util.concurrent.ThreadPoolExecutor.addWorker(ThreadPoolExecutor.java:920)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1338)
at okhttp3.ConnectionPool.put(ConnectionPool.java:135)
at okhttp3.OkHttpClient$1.put(OkHttpClient.java:149)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:188)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
at okhttp3.RealCall.access$100(RealCall.java:33)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:120)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
09-08 13:25:06.372 31080-31080/com.tutorialproject D/SensorManager: unregisterListener ::
09-08 13:25:06.852 31080-31185/com.tutorialproject W/unknown:React: Tried to enqueue runnable on already finished thread: 'native_modules... dropping Runnable.
09-08 13:25:06.852 31080-31185/com.tutorialproject W/MessageQueue: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {246b7490} sending message to a Handler on a dead thread
java.lang.IllegalStateException: Handler (com.facebook.react.bridge.queue.MessageQueueThreadHandler) {246b7490} sending message to a Handler on a dead thread
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:325)
at android.os.Handler.enqueueMessage(Handler.java:631)
at android.os.Handler.sendMessageAtTime(Handler.java:600)
at android.os.Handler.sendMessageDelayed(Handler.java:570)
at android.os.Handler.post(Handler.java:326)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl.runOnQueue(MessageQueueThreadImpl.java:61)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:145)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:196)
at java.lang.Thread.run(Thread.java:818)
09-08 13:25:06.862 31080-3792/com.tutorialproject W/ContextImpl: Failed to ensure directory: /storage/extSdCard/Android/data/com.tutorialproject/cache
09-08 13:25:11.362 31080-31088/com.tutorialproject W/art: Suspending all threads took: 5.930ms

这是一个非常简单的项目,只有几个文本组件,所以我没有做任何请求。所有的网络通信都是由于远程调试。

因为这是一个 OutOfMemory 问题,我尝试将 android:largeHeap="true" 添加到 Manifest.xml,但没有任何变化。该应用程序达到 32Mb 的消耗并终止。

我修改了该应用程序,因此它加载了一个包含图像的组件 5000 次。在禁用调试的情况下,应用程序最多分配 70Mb 并且运行良好。我可以在整个屏幕上滚动,没有任何崩溃。当我启用远程调试时,我工作了一段时间,直到它尝试分配更多内存并再次崩溃。我可以在启用调试的情况下再次启动该应用程序,它启动良好,但一段时间后再次崩溃。

恕我直言,React Native 远程调试功能在分配新内存时存在问题(由于某些原因,即使应用程序停止,它也会消耗大量内存)。

关于android - 尝试在 Chrome 中调试时 React Native Android 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34362347/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com