Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.facebook.react.uimanager.IllegalViewOperationException #21388

Closed
krmao opened this issue Sep 28, 2018 · 6 comments
Closed

com.facebook.react.uimanager.IllegalViewOperationException #21388

krmao opened this issue Sep 28, 2018 · 6 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@krmao
Copy link

krmao commented Sep 28, 2018

com.facebook.react.uimanager.NativeViewHierarchyManager.void addRootViewGroup(int,android.view.ViewGroup,com.facebook.react.uimanager.ThemedReactContext)(SourceFile:509)
--
2 com.facebook.react.uimanager.NativeViewHierarchyManager.void addRootView(int,com.facebook.react.uimanager.common.SizeMonitoringFrameLayout,com.facebook.react.uimanager.ThemedReactContext)(SourceFile:501)
3 com.facebook.react.uimanager.UIViewOperationQueue.void addRootView(int,com.facebook.react.uimanager.common.SizeMonitoringFrameLayout,com.facebook.react.uimanager.ThemedReactContext)(SourceFile:607)
4 com.facebook.react.uimanager.UIImplementation.void registerRootView(com.facebook.react.uimanager.common.SizeMonitoringFrameLayout,int,com.facebook.react.uimanager.ThemedReactContext)(SourceFile:211)
5 com.facebook.react.uimanager.UIManagerModule.int addRootView(com.facebook.react.uimanager.common.SizeMonitoringFrameLayout)(SourceFile:304)
6 com.facebook.react.ReactInstanceManager.void attachRootViewToInstance(com.facebook.react.ReactRootView,com.facebook.react.bridge.CatalystInstance)(SourceFile:1012)
7 com.facebook.react.ReactInstanceManager.void attachRootView(com.facebook.react.ReactRootView)(SourceFile:723)
8 com.facebook.react.ReactRootView.void attachToReactInstanceManager()(SourceFile:527)
9 com.facebook.react.ReactRootView.void startReactApplication(com.facebook.react.ReactInstanceManager,java.lang.String,android.os.Bundle)(SourceFile:356)
10 com.saike.module.rn.ReactActivity$startReactApplication$1.void run()(SourceFile:180)
11 android.os.Handler.handleCallback(Handler.java:808)
12 android.os.Handler.dispatchMessage(Handler.java:101)
13 android.os.Looper.loop(Looper.java:166)
14 android.app.ActivityThread.main(ActivityThread.java:7425)
15 java.lang.reflect.Method.invoke(Native Method)
16 com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)
17 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)


异常进程#线程

com.saike.android.mongo#main(1)

用户 ID

unknown

发生时间

2018-09-28 07:01:02

上报时间

2018-09-28 07:01:03

应用包名

com.saike.android.mongo

应用版本

5.0.1

使用时长

1 分 10 秒

前后台状态

前台

设备机型

华为 MHA AL00 真机测试

系统版本

Android 8.0.0,level 26

ROM

HuaWei/EMOTION

CPU架构

armeabi-v7a

上报 ID | 版本 | 异常上报时间 | 设备 | 系统版本
-- | -- | -- | -- | --
# 3520525.0.12018-09-28 07:01:03 685华为 MHA AL00Android 8.0.0,level 26 | # 352052 | 5.0.1 | 2018-09-28 07:01:03 685 | 华为 MHA AL00 | Android 8.0.0,level 26
# 352052 | 5.0.1 | 2018-09-28 07:01:03 685 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3400465.0.12018-09-28 05:51:02 644荣耀 FRD AL10Android 8.0.0,level 26 | # 340046 | 5.0.1 | 2018-09-28 05:51:02 644 | 荣耀 FRD AL10 | Android 8.0.0,level 26
# 340046 | 5.0.1 | 2018-09-28 05:51:02 644 | 荣耀 FRD AL10 | Android 8.0.0,level 26
# 3440525.0.12018-09-27 20:57:51 492华为 BLA AL00Android 8.1.0,level 27 | # 344052 | 5.0.1 | 2018-09-27 20:57:51 492 | 华为 BLA AL00 | Android 8.1.0,level 27
# 344052 | 5.0.1 | 2018-09-27 20:57:51 492 | 华为 BLA AL00 | Android 8.1.0,level 27
# 3750455.02018-09-27 18:13:51 736华为 ALP AL00Android 8.1.0,level 27 | # 375045 | 5.0 | 2018-09-27 18:13:51 736 | 华为 ALP AL00 | Android 8.1.0,level 27
# 375045 | 5.0 | 2018-09-27 18:13:51 736 | 华为 ALP AL00 | Android 8.1.0,level 27
# 3550505.0.12018-09-27 16:44:44 224华为 NXT-AL10Android 7.0,level 24 | # 355050 | 5.0.1 | 2018-09-27 16:44:44 224 | 华为 NXT-AL10 | Android 7.0,level 24
# 355050 | 5.0.1 | 2018-09-27 16:44:44 224 | 华为 NXT-AL10 | Android 7.0,level 24
# 3470465.02018-09-27 16:37:21 879华为 MHA AL00Android 8.0.0,level 26 | # 347046 | 5.0 | 2018-09-27 16:37:21 879 | 华为 MHA AL00 | Android 8.0.0,level 26
# 347046 | 5.0 | 2018-09-27 16:37:21 879 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3440505.0.12018-09-27 15:57:41 317荣耀 FRD AL10Android 8.0.0,level 26 | # 344050 | 5.0.1 | 2018-09-27 15:57:41 317 | 荣耀 FRD AL10 | Android 8.0.0,level 26
# 344050 | 5.0.1 | 2018-09-27 15:57:41 317 | 荣耀 FRD AL10 | Android 8.0.0,level 26
# 3730455.0.12018-09-27 14:28:55 990华为 HWI AL00Android 8.0.0,level 26 | # 373045 | 5.0.1 | 2018-09-27 14:28:55 990 | 华为 HWI AL00 | Android 8.0.0,level 26
# 373045 | 5.0.1 | 2018-09-27 14:28:55 990 | 华为 HWI AL00 | Android 8.0.0,level 26
# 3450405.0.12018-09-27 13:41:31 811华为 MHA AL00Android 8.0.0,level 26 | # 345040 | 5.0.1 | 2018-09-27 13:41:31 811 | 华为 MHA AL00 | Android 8.0.0,level 26
# 345040 | 5.0.1 | 2018-09-27 13:41:31 811 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3690425.0.12018-09-27 12:21:05 029小米 MI 8Android 8.1.0,level 27 | # 369042 | 5.0.1 | 2018-09-27 12:21:05 029 | 小米 MI 8 | Android 8.1.0,level 27
# 369042 | 5.0.1 | 2018-09-27 12:21:05 029 | 小米 MI 8 | Android 8.1.0,level 27
# 3510475.0.12018-09-27 08:30:17 134华为 MHA AL00Android 8.0.0,level 26 | # 351047 | 5.0.1 | 2018-09-27 08:30:17 134 | 华为 MHA AL00 | Android 8.0.0,level 26
# 351047 | 5.0.1 | 2018-09-27 08:30:17 134 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3400395.0.12018-09-27 00:11:46 588华为 MHA AL00Android 8.0.0,level 26 | # 340039 | 5.0.1 | 2018-09-27 00:11:46 588 | 华为 MHA AL00 | Android 8.0.0,level 26
# 340039 | 5.0.1 | 2018-09-27 00:11:46 588 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3690415.0.12018-09-26 21:27:28 998一加 A6000Android 8.1.0,level 27 | # 369041 | 5.0.1 | 2018-09-26 21:27:28 998 | 一加 A6000 | Android 8.1.0,level 27
# 369041 | 5.0.1 | 2018-09-26 21:27:28 998 | 一加 A6000 | Android 8.1.0,level 27
# 3640455.0.12018-09-26 18:59:45 524小米 MI 8Android 8.1.0,level 27 | # 364045 | 5.0.1 | 2018-09-26 18:59:45 524 | 小米 MI 8 | Android 8.1.0,level 27
# 364045 | 5.0.1 | 2018-09-26 18:59:45 524 | 小米 MI 8 | Android 8.1.0,level 27
# 3730405.02018-09-26 11:23:17 837华为 VTR TL00Android 8.0.0,level 26 | # 373040 | 5.0 | 2018-09-26 11:23:17 837 | 华为 VTR TL00 | Android 8.0.0,level 26
# 373040 | 5.0 | 2018-09-26 11:23:17 837 | 华为 VTR TL00 | Android 8.0.0,level 26
# 3610325.0.12018-09-26 10:11:40 918三星 SM N9600Android 8.1.0,level 27 | # 361032 | 5.0.1 | 2018-09-26 10:11:40 918 | 三星 SM N9600 | Android 8.1.0,level 27
# 361032 | 5.0.1 | 2018-09-26 10:11:40 918 | 三星 SM N9600 | Android 8.1.0,level 27
# 3510425.0.12018-09-26 10:08:25 769华为 MHA AL00Android 8.0.0,level 26 | # 351042 | 5.0.1 | 2018-09-26 10:08:25 769 | 华为 MHA AL00 | Android 8.0.0,level 26
# 351042 | 5.0.1 | 2018-09-26 10:08:25 769 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3460395.0.12018-09-26 01:37:33 286一加 A5010Android 8.1.0,level 27 | # 346039 | 5.0.1 | 2018-09-26 01:37:33 286 | 一加 A5010 | Android 8.1.0,level 27
# 346039 | 5.0.1 | 2018-09-26 01:37:33 286 | 一加 A5010 | Android 8.1.0,level 27
# 3740395.02018-09-25 21:45:14 757小米 MIX 2SAndroid 8.0.0,level 26 | # 374039 | 5.0 | 2018-09-25 21:45:14 757 | 小米 MIX 2S | Android 8.0.0,level 26
# 374039 | 5.0 | 2018-09-25 21:45:14 757 | 小米 MIX 2S | Android 8.0.0,level 26
# 3420305.02018-09-25 19:39:55 205荣耀 PRA TL10Android 8.0.0,level 26 | # 342030 | 5.0 | 2018-09-25 19:39:55 205 | 荣耀 PRA TL10 | Android 8.0.0,level 26
# 342030 | 5.0 | 2018-09-25 19:39:55 205 | 荣耀 PRA TL10 | Android 8.0.0,level 26
# 3760295.02018-09-25 14:32:52 367华为 NXT-AL10Android 7.0,level 24 | # 376029 | 5.0 | 2018-09-25 14:32:52 367 | 华为 NXT-AL10 | Android 7.0,level 24
# 376029 | 5.0 | 2018-09-25 14:32:52 367 | 华为 NXT-AL10 | Android 7.0,level 24
# 3550425.02018-09-25 12:39:08 441三星 SM N9508Android 8.0.0,level 26 | # 355042 | 5.0 | 2018-09-25 12:39:08 441 | 三星 SM N9508 | Android 8.0.0,level 26
# 355042 | 5.0 | 2018-09-25 12:39:08 441 | 三星 SM N9508 | Android 8.0.0,level 26
# 3690395.02018-09-25 12:14:02 461荣耀 FRD DL00Android 7.0,level 24 | # 369039 | 5.0 | 2018-09-25 12:14:02 461 | 荣耀 FRD DL00 | Android 7.0,level 24
# 369039 | 5.0 | 2018-09-25 12:14:02 461 | 荣耀 FRD DL00 | Android 7.0,level 24
# 3610285.02018-09-25 07:41:02 479小米 MIX 2SAndroid 8.0.0,level 26 | # 361028 | 5.0 | 2018-09-25 07:41:02 479 | 小米 MIX 2S | Android 8.0.0,level 26
# 361028 | 5.0 | 2018-09-25 07:41:02 479 | 小米 MIX 2S | Android 8.0.0,level 26
# 3640315.02018-09-24 12:52:51 621华为 LON AL00Android 8.0.0,level 26 | # 364031 | 5.0 | 2018-09-24 12:52:51 621 | 华为 LON AL00 | Android 8.0.0,level 26
# 364031 | 5.0 | 2018-09-24 12:52:51 621 | 华为 LON AL00 | Android 8.0.0,level 26
# 3750305.02018-09-24 10:52:50 272华为 MHA AL00Android 8.0.0,level 26 | # 375030 | 5.0 | 2018-09-24 10:52:50 272 | 华为 MHA AL00 | Android 8.0.0,level 26
# 375030 | 5.0 | 2018-09-24 10:52:50 272 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3380325.02018-09-24 09:43:14 042小米 MI 8Android 8.1.0,level 27 | # 338032 | 5.0 | 2018-09-24 09:43:14 042 | 小米 MI 8 | Android 8.1.0,level 27
# 338032 | 5.0 | 2018-09-24 09:43:14 042 | 小米 MI 8 | Android 8.1.0,level 27
# 3550365.02018-09-23 22:54:34 236华为 NXT-AL10Android 8.0.0,level 26 | # 355036 | 5.0 | 2018-09-23 22:54:34 236 | 华为 NXT-AL10 | Android 8.0.0,level 26
# 355036 | 5.0 | 2018-09-23 22:54:34 236 | 华为 NXT-AL10 | Android 8.0.0,level 26
# 3570285.02018-09-23 22:11:39 681华为 MHA AL00Android 8.0.0,level 26 | # 357028 | 5.0 | 2018-09-23 22:11:39 681 | 华为 MHA AL00 | Android 8.0.0,level 26
# 357028 | 5.0 | 2018-09-23 22:11:39 681 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3530335.02018-09-23 21:14:24 166华为 BLA AL00Android 8.1.0,level 27 | # 353033 | 5.0 | 2018-09-23 21:14:24 166 | 华为 BLA AL00 | Android 8.1.0,level 27
# 353033 | 5.0 | 2018-09-23 21:14:24 166 | 华为 BLA AL00 | Android 8.1.0,level 27
# 3650215.02018-09-23 17:03:33 452华为 MHA AL00Android 8.0.0,level 26 | # 365021 | 5.0 | 2018-09-23 17:03:33 452 | 华为 MHA AL00 | Android 8.0.0,level 26
# 365021 | 5.0 | 2018-09-23 17:03:33 452 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3750285.02018-09-23 16:53:57 367华为 MHA AL00Android 8.0.0,level 26 | # 375028 | 5.0 | 2018-09-23 16:53:57 367 | 华为 MHA AL00 | Android 8.0.0,level 26
# 375028 | 5.0 | 2018-09-23 16:53:57 367 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3640285.02018-09-23 16:52:07 065小米 MIX 2Android 8.0.0,level 26 | # 364028 | 5.0 | 2018-09-23 16:52:07 065 | 小米 MIX 2 | Android 8.0.0,level 26
# 364028 | 5.0 | 2018-09-23 16:52:07 065 | 小米 MIX 2 | Android 8.0.0,level 26
# 3440305.02018-09-23 15:24:35 784华为 BLA AL00Android 8.1.0,level 27 | # 344030 | 5.0 | 2018-09-23 15:24:35 784 | 华为 BLA AL00 | Android 8.1.0,level 27
# 344030 | 5.0 | 2018-09-23 15:24:35 784 | 华为 BLA AL00 | Android 8.1.0,level 27
# 3660355.02018-09-23 15:12:01 874华为 MHA AL00Android 8.0.0,level 26 | # 366035 | 5.0 | 2018-09-23 15:12:01 874 | 华为 MHA AL00 | Android 8.0.0,level 26
# 366035 | 5.0 | 2018-09-23 15:12:01 874 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3620195.02018-09-23 13:32:54 889华为 HWI TL00Android 8.0.0,level 26 | # 362019 | 5.0 | 2018-09-23 13:32:54 889 | 华为 HWI TL00 | Android 8.0.0,level 26
# 362019 | 5.0 | 2018-09-23 13:32:54 889 | 华为 HWI TL00 | Android 8.0.0,level 26
# 3730245.02018-09-23 11:50:38 745一加 A5000Android 8.1.0,level 27 | # 373024 | 5.0 | 2018-09-23 11:50:38 745 | 一加 A5000 | Android 8.1.0,level 27
# 373024 | 5.0 | 2018-09-23 11:50:38 745 | 一加 A5000 | Android 8.1.0,level 27
# 3730235.02018-09-23 10:54:40 837荣耀 DUK AL20Android 8.0.0,level 26 | # 373023 | 5.0 | 2018-09-23 10:54:40 837 | 荣耀 DUK AL20 | Android 8.0.0,level 26
# 373023 | 5.0 | 2018-09-23 10:54:40 837 | 荣耀 DUK AL20 | Android 8.0.0,level 26
# 3740295.02018-09-23 10:53:21 409小米 MI 6Android 8.0.0,level 26 | # 374029 | 5.0 | 2018-09-23 10:53:21 409 | 小米 MI 6 | Android 8.0.0,level 26
# 374029 | 5.0 | 2018-09-23 10:53:21 409 | 小米 MI 6 | Android 8.0.0,level 26
# 3570275.02018-09-23 09:57:52 755华为 NXT-AL10Android 8.0.0,level 26 | # 357027 | 5.0 | 2018-09-23 09:57:52 755 | 华为 NXT-AL10 | Android 8.0.0,level 26
# 357027 | 5.0 | 2018-09-23 09:57:52 755 | 华为 NXT-AL10 | Android 8.0.0,level 26
# 3500265.02018-09-23 09:56:07 917华为 MHA AL00Android 8.0.0,level 26 | # 350026 | 5.0 | 2018-09-23 09:56:07 917 | 华为 MHA AL00 | Android 8.0.0,level 26
# 350026 | 5.0 | 2018-09-23 09:56:07 917 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3460255.02018-09-23 09:27:06 816华为 MHA AL00Android 8.0.0,level 26 | # 346025 | 5.0 | 2018-09-23 09:27:06 816 | 华为 MHA AL00 | Android 8.0.0,level 26
# 346025 | 5.0 | 2018-09-23 09:27:06 816 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3460245.02018-09-23 08:50:37 130荣耀 STF AL10Android 8.0.0,level 26 | # 346024 | 5.0 | 2018-09-23 08:50:37 130 | 荣耀 STF AL10 | Android 8.0.0,level 26
# 346024 | 5.0 | 2018-09-23 08:50:37 130 | 荣耀 STF AL10 | Android 8.0.0,level 26
# 3400255.02018-09-23 07:42:32 317华为 MHA AL00Android 8.0.0,level 26 | # 340025 | 5.0 | 2018-09-23 07:42:32 317 | 华为 MHA AL00 | Android 8.0.0,level 26
# 340025 | 5.0 | 2018-09-23 07:42:32 317 | 华为 MHA AL00 | Android 8.0.0,level 26
# 3750205.02018-09-22 19:55:30 099华为 NXT-CL00Android 8.0.0,level 26 | # 375020 | 5.0 | 2018-09-22 19:55:30 099 | 华为 NXT-CL00 | Android 8.0.0,level 26
# 375020 | 5.0 | 2018-09-22 19:55:30 099 | 华为 NXT-CL00 | Android 8.0.0,level 26
# 3420195.02018-09-22 15:14:51 274华为 NXT-AL10Android 8.0.0,level 26 | # 342019 | 5.0 | 2018-09-22 15:14:51 274 | 华为 NXT-AL10 | Android 8.0.0,level 26
# 342019 | 5.0 | 2018-09-22 15:14:51 274 | 华为 NXT-AL10 | Android 8.0.0,level 26
# 3550265.02018-09-22 12:00:22 786VIVO Z1IAndroid 8.1.0,level 27 | # 355026 | 5.0 | 2018-09-22 12:00:22 786 | VIVO Z1I | Android 8.1.0,level 27
# 355026 | 5.0 | 2018-09-22 12:00:22 786 | VIVO Z1I | Android 8.1.0,level 27
# 3380245.02018-09-22 11:46:49 787荣耀 BKL AL20Android 8.0.0,level 26 | # 338024 | 5.0 | 2018-09-22 11:46:49 787 | 荣耀 BKL AL20 | Android 8.0.0,level 26
# 338024 | 5.0 | 2018-09-22 11:46:49 787 | 荣耀 BKL AL20 | Android 8.0.0,level 26
# 3500215.02018-09-22 10:39:54 835华为 WAS AL00Android 7.0,level 24 | # 350021 | 5.0 | 2018-09-22 10:39:54 835 | 华为 WAS AL00 | Android 7.0,level 24
# 350021 | 5.0 | 2018-09-22 10:39:54 835 | 华为 WAS AL00 | Android 7.0,level 24
# 3630245.02018-09-22 10:01:31 825华为 MHA AL00Android 8.0.0,level 26 | # 363024 | 5.0 | 2018-09-22 10:01:31 825 | 华为 MHA AL00 | Android 8.0.0,level 26
# 363024 | 5.0 | 2018-09-22 10:01:31 825 | 华为 MHA AL00 | Android 8.0.0,level 26


Environment

Environment:
  OS: macOS Sierra 10.12.6
  Node: 8.9.3
  Yarn: Not Found
  npm: 6.1.0
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.1 AI-173.4907809

Packages: (wanted => installed)
  react: ^16.3.1 => 16.3.1
  react-native: 0.55.4 => 0.55.4

Description

Trying to add a root view with an explicit id already set. React Native uses the id field to track react tags and will overwrite this field. If that is fine, explicitly overwrite the id field to View.NO_ID before calling addRootView.

maybe the key problem

this bug I think may be open more than two ReactActivity by quick clicked button.
because ReactActivity use singleton ReactInstanceManager, and thread security is unsafe.

ReactInstanceManager.java

  @ThreadConfined(UI)
  public void attachRootView(ReactRootView rootView) {
    UiThreadUtil.assertOnUiThread();
    mAttachedRootViews.add(rootView);

    // Reset view content as it's going to be populated by the application content from JS.
    rootView.removeAllViews();
    rootView.setId(View.NO_ID);

    // If react context is being created in the background, JS application will be started
    // automatically when creation completes, as root view is part of the attached root view list.
    ReactContext currentContext = getCurrentReactContext();
    if (mCreateReactContextThread == null && currentContext != null) {
      attachRootViewToInstance(rootView, currentContext.getCatalystInstance());
    }
  }

NativeViewHierarchyManager.java

  protected synchronized final void addRootViewGroup(
      int tag,
      ViewGroup view,
      ThemedReactContext themedContext) {
    if (view.getId() != View.NO_ID) {
      throw new IllegalViewOperationException(
          "Trying to add a root view with an explicit id already set. React Native uses " +
          "the id field to track react tags and will overwrite this field. If that is fine, " +
          "explicitly overwrite the id field to View.NO_ID before calling addRootView.");
    }

    mTagsToViews.put(tag, view);
    mTagsToViewManagers.put(tag, mRootViewManager);
    mRootTags.put(tag, true);
    view.setId(tag);
  }
@react-native-bot
Copy link
Collaborator

Can you run react-native info and edit your issue to include these results under the Environment section?

If you believe this information is irrelevant to the reported issue, you may write [skip envinfo] under Environment to let us know.

@krmao
Copy link
Author

krmao commented Sep 28, 2018

sorry for that , I have update the Environment section. @react-native-bot

@react-native-bot
Copy link
Collaborator

It looks like you are using an older version of React Native. Please update to the latest release, v0.57 and verify if the issue still exists.

The ":rewind:Old Version" label will be removed automatically once you edit your original post with the results of running react-native info on a project using the latest release.

@react-native-bot
Copy link
Collaborator

I am closing this issue because it does not appear to have been verified on the latest release, and there has been no followup in a while.

If you found this thread after encountering the same issue in the latest release, please feel free to create a new issue with up-to-date information by clicking here.

@react-native-bot react-native-bot added the Ran Commands One of our bots successfully processed a command. label Oct 13, 2018
@s349856186
Copy link

@krmao do you fix it? how to do

@krmao
Copy link
Author

krmao commented Dec 20, 2018

hi @s349856186 below is my code to fix this bug

        @JvmStatic
        @JvmOverloads
        internal fun startForResult(context: Context?, component: String? = null, extras: Bundle, intentFlag: Int? = null, requestCode: Int, callback: ((requestCode: Int, resultCode: Int, data: Intent?) -> Unit?)? = null) {
            if (CXValueUtil.isDoubleClicked(700)) {
                CXLogUtil.e("ReactActivity", "detected jump to ReactActivity with doubleClicked, cancel jump !")
                return
            }

            if (!CXNetworkUtil.isNetworkAvailable()) {
                CXToastUtil.show("网络不给力")
                callback?.invoke(requestCode, Activity.RESULT_CANCELED, null)
                return
            }

            val intent = Intent(context, ReactActivity::class.java)
            intentFlag?.let { intent.addFlags(it) }
            intent.putExtra(KEY_REQUEST_CODE, requestCode)
            intent.putExtra(KEY_START_COMPONENT, component)
            intent.putExtras(extras)

            if (context is Activity) {
                startActivityForResult(context, intent, 0, null, callback)
            } else {
                context?.startActivity(intent)
                CXLogUtil.e(ReactManager.TAG, "context is not Activity, can't startActivityForResult!")
                callback?.invoke(requestCode, Activity.RESULT_CANCELED, null)
            }
        }
    @Volatile
    private var lastClickedTime: Long = 0L

    @JvmStatic
    @JvmOverloads
    fun isDoubleClicked(interval: Int = 200): Boolean {
        val isDoubleClicked = (System.currentTimeMillis() - lastClickedTime) <= interval // double check
        lastClickedTime = System.currentTimeMillis()
        return isDoubleClicked
    }

the key is intercept start to ReactActivity by limit the time by CXValueUtil.isDoubleClicked(700)

hi @react-native-bot I fixed this by another way :)

@facebook facebook locked as resolved and limited conversation to collaborators Oct 13, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Oct 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

3 participants