square / react-native-square-reader-sdk

React Native Plugin for Square Reader SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Square reader sdk invoked the app crash after upgraded to expo44

GuoXiaoyang opened this issue · comments

Describe the issue

After I upgraded my app to Expo 44 with bare workflow and the android api level is upgraded to 30, the square reader did not work properly on the android devices. It has several problems:
Problem 1: App crashed sometimes only in the production mode, below are the steps :

  1. build a release bundle(apk)
  2. install the apk on an android device(device info will be listed below)
  3. authorize with the sqaure development code
  4. enter reader settings and start connect a reader
  5. give the app permissions
  6. after give all the 3 permissions, the app crashed and reload

Logcat listed somer error when app crashed:

2022-01-05 15:12:36.420 11915-11915/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.guoxiaoyang.moegoreleasetest, PID: 11915
    java.lang.IllegalStateException: Scope com.squareup.container.WorkflowScope was destroyed
        at shadow.mortar.MortarScope.assertNotDead(MortarScope.java:264)
        at shadow.mortar.MortarScope.findService(MortarScope.java:131)
        at shadow.mortar.MortarScope.getService(MortarScope.java:116)
        at com.squareup.container.inversion.FlowRunnerKt.getFlow(FlowRunner.kt:76)
        at com.squareup.ui.main.GatekeepersRootWorkflow$render$1$1.invokeSuspend(GatekeepersRootWorkflow.kt:99)
        at com.squareup.ui.main.GatekeepersRootWorkflow$render$1$1.invoke(Unknown Source:8)
        at com.squareup.ui.main.GatekeepersRootWorkflow$render$1$1.invoke(Unknown Source:4)
        at com.squareup.workflow1.InterceptedRenderContext$runningSideEffect$withScopeReceiver$1.invokeSuspend(WorkflowInterceptor.kt:306)
        at com.squareup.workflow1.InterceptedRenderContext$runningSideEffect$withScopeReceiver$1.invoke(Unknown Source:8)
        at com.squareup.workflow1.InterceptedRenderContext$runningSideEffect$withScopeReceiver$1.invoke(Unknown Source:2)
        at com.squareup.workflow1.InterceptedRenderContext$runningSideEffect$1$1.invokeSuspend(WorkflowInterceptor.kt:311)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
        at kotlinx.coroutines.EventLoop.processUnconfinedEvent(EventLoop.common.kt:69)
        at kotlinx.coroutines.DispatchedTaskKt.resumeUnconfined(DispatchedTask.kt:244)
        at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:161)
        at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:398)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:432)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:421)
        at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:329)
        at kotlinx.coroutines.flow.SharedFlowImpl.tryEmit(SharedFlow.kt:368)
        at com.squareup.gatekeeper.Gatekeeping.updateGatekeepers(Gatekeeping.kt:31)
        at com.squareup.ui.main.Historian.nextHistoryToShowWhileResetting(Historian.kt:343)
        at com.squareup.ui.main.Historian.resetHistory(Historian.kt:239)
        at com.squareup.ui.main.WorkflowPosContainer.resetHistory(WorkflowPosContainer.kt:184)
        at com.squareup.ui.systempermissions.EnableDeviceSettingsPresenter.updatePermissionsState(EnableDeviceSettingsPresenter.java:137)
        at com.squareup.ui.systempermissions.EnableDeviceSettingsPresenter.onResume(EnableDeviceSettingsPresenter.java:82)
        at com.squareup.pauses.PauseAndResumePresenter.activityResumed(PauseAndResumePresenter.java:72)
        at com.squareup.ui.main.MainActivity.onResume(MainActivity.java:218)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1454)
        at android.app.Activity.performResume(Activity.java:8111)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4647)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4690)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2267)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.app.ActivityThread.main(ActivityThread.java:8167)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
2022-01-05 15:12:36.571 1429-1953/? E/InputDispatcher: channel '825c9b com.guoxiaoyang.moegoreleasetest/com.squareup.ui.main.ApiMainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2022-01-05 15:12:36.614 1429-1953/? E/InputDispatcher: channel 'fbd0249 com.guoxiaoyang.moegoreleasetest/com.guoxiaoyang.moegoreleasetest.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
2022-01-05 15:12:36.617 2284-2339/? E/RequestManager_FLP: [LocationManager] Location remove 60461c4 from com.guoxiaoyang.moegoreleasetest
2022-01-05 15:12:36.620 1429-1575/? E/WindowManager: RemoteException occurs on reporting focusChanged, w=Window{825c9b u0 com.guoxiaoyang.moegoreleasetest/com.squareup.ui.main.ApiMainActivity EXITING}
    android.os.DeadObjectException
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:575)
        at android.view.IWindow$Stub$Proxy.windowFocusChanged(IWindow.java:829)
        at com.android.server.wm.WindowState.reportFocusChangedSerialized(WindowState.java:3800)
        at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:5438)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.os.HandlerThread.run(HandlerThread.java:67)
        at com.android.server.ServiceThread.run(ServiceThread.java:44)
2022-01-05 15:12:36.626 1429-1483/? E/WindowManager: win=Window{825c9b u0 com.guoxiaoyang.moegoreleasetest/com.squareup.ui.main.ApiMainActivity EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1249 com.android.server.wm.AppWindowToken.destroySurfaces:1230 com.android.server.wm.WindowState.onExitAnimationDone:5189 com.android.server.wm.-$$Lambda$01bPtngJg5AqEoOWfW3rWfV7MH4.accept:2 java.util.ArrayList.forEach:1262 com.android.server.wm.AppWindowToken.onAnimationFinished:3941 com.android.server.wm.AppWindowToken.commitVisibility:914 
2022-01-05 15:12:36.642 2284-2339/? E/RequestManager_FLP: [LocationManager] Location remove 7902a9 from com.guoxiaoyang.moegoreleasetest
2022-01-05 15:12:37.629 1429-1577/? E/WindowManager: win=Window{47aa39f u0 Splash Screen com.guoxiaoyang.moegoreleasetest EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true win.mViewVisibility=0 caller=com.android.server.wm.AppWindowToken.destroySurfaces:1249 com.android.server.wm.AppWindowToken.destroySurfaces:1230 com.android.server.wm.WindowState.onExitAnimationDone:5189 com.android.server.wm.WindowStateAnimator.onAnimationFinished:320 com.android.server.wm.WindowState.onAnimationFinished:5630 com.android.server.wm.-$$Lambda$yVRF8YoeNdTa8GR1wDStVsHu8xM.run:2 com.android.server.wm.SurfaceAnimator.lambda$getFinishedCallback$0$SurfaceAnimator:100 
2022-01-05 15:12:37.633 1076-1076/? E/audit: type=1327 audit(1641366757.619:412134): proctitle="com.guoxiaoyang.moegoreleasetest"

Problem 2: the button did not response while trying to connect a reader, steps below:

  1. after the app crashed and reload, click the reader settings in the demo app
  2. enter the Square reader connecting page, click the Connect a reader button
  3. it can not have any response, thus I can't connect to a reader
  4. sometimes I can connect to a reader, but the connected reader name does not response to modify the setting

Problem 2 can be reproduced both in the production mode and the debug mode(react-native android).
Logcat did not show any related error of problem 2.

Environment:

  - platform: Android
  - OS and version: Sumsung Note 9
  - Android version: Android 10
  - Kernel version: 4.9.186-22986754
  - dev environment: MacOS
  - Reader SDK version: 1.5.1

System:
    OS: macOS 12.0.1
    CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
    Memory: 772.26 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm
    Watchman: HEAD-49f3831 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.11.2 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    Android SDK:
      API Levels: 28, 29, 30, 31
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0
      System Images: android-29 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 2020.3 AI-203.7717.56.2031.7678000
    Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_301 - /Library/Java/JavaVirtualMachines/jdk1.8.0_301.jdk/Contents/Home/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.3 => 0.64.3 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

reproduce

This demo with the square reader quickstart code can reproduce both the two problems above: https://github.com/GuoXiaoyang/moego-release-test

Screen Recording

Screen_Recording_20220105-154301_moego-release-test.mp4

Additional context

@GuoXiaoyang thanks for reporting this issue! Do you mind to share the merchant Id and application id you used?

I think this information is a bit sensitive. In fact, we've spoken to you and you've told me that upgrading to 1.5.3 is feasible.
But, the app still crashed after the upgrade.

You can use the demo I provided and fill in the test token and test app id in this file to reproduce it.

Hey, I tried to replicate the issue from the sample app. The build is working fine. I tested it for debug mode on the simulator and a real device. Also, tested for a release signed apk on my device. It is working fine. I am attaching a video for it as well

XRecorder_11032022_000218.mp4

.

Hi, really appreciated your trial. The crash could happen when I followed these steps:

  1. Uninstall the old app
  2. Install the apk with release mode
  3. After authorized, click the Reader Settings(Do not charge at this step)
  4. Give three permissions, then the app crashed and restarted

@GuoXiaoyang thanks for sharing that step, we are able to repro it now. Do you see this only the first time you open a newly installed app? Curious if that's an error blocking customers from using the app or just an annoying issue the first time use the app.

@hukid Mostly the problem only bothers users who use the app first time.
But a small number of users(especially with Android 7.0) reported that the problem persisted every time he tried to connect the reader.

Do you always see this bit?

    android.os.DeadObjectException
        at android.os.BinderProxy.transactNative(Native Method)
        at android.os.BinderProxy.transact(BinderProxy.java:575)
        at android.view.IWindow$Stub$Proxy.windowFocusChanged(IWindow.java:829)
        at com.android.server.wm.WindowState.reportFocusChangedSerialized(WindowState.java:3800)
        at com.android.server.wm.WindowManagerService$H.handleMessage(WindowManagerService.java:5438)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:237)
        at android.os.HandlerThread.run(HandlerThread.java:67)
        at com.android.server.ServiceThread.run(ServiceThread.java:44)

I'm wondering if Android is killing us off and the rest of the stack is death throes

Hey guys is there any update on this? I'm seeing the exact same behaviour when displaying the settings page for the first time and the checkout is crashing altogether on Android 12 devices.

Sorry for the delay @AngeloMateus
We need to give blutooth_connect permission for android 12 version
https://developer.android.com/guide/topics/connectivity/bluetooth/permissions

Will resolve this issue as soon as possible and update you.

Sorry @AngeloMateus
Currently our plugin is not supported expo it's for React-native only but will try to sort it out this issue
Thank you !