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

Python code not work on APK release mode #236

Closed
kmf909 opened this issue Mar 10, 2020 · 6 comments
Closed

Python code not work on APK release mode #236

kmf909 opened this issue Mar 10, 2020 · 6 comments

Comments

@kmf909
Copy link

kmf909 commented Mar 10, 2020

Hi, this issue related to email that out team member (hamraa.osatechnology@gmail.com) send to you on 20 Feb 2020. below is the log. A bit of a background, our team develop an android app using flutter, the issue were the app working during debug mode but when we build apk and install the app it does not produce result from the python code.

03-09 22:54:53.418 23530 23559 I flutter : [2020-03-09 22:54:53.418780 | ConsoleHandler | INFO] PlatformException(error, ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770., null)
03-09 22:54:53.419 23530 23559 I flutter : [2020-03-09 22:54:53.419206 | ConsoleHandler | INFO] 
03-09 22:54:53.419 23530 23559 I flutter : [2020-03-09 22:54:53.419436 | ConsoleHandler | INFO] ------- STACK TRACE -------
03-09 22:54:53.421 23530 23559 I flutter : [2020-03-09 22:54:53.421478 | ConsoleHandler | INFO] #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569)
03-09 22:54:53.421 23530 23559 I flutter : [2020-03-09 22:54:53.421772 | ConsoleHandler | INFO] #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321)
03-09 22:54:53.421 23530 23559 I flutter : [2020-03-09 22:54:53.421882 | ConsoleHandler | INFO] <asynchronous suspension>
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.421947 | ConsoleHandler | INFO] #2      ChaquopyPlatform.initChaquopy (package:flobo/shared/chaquopy_platform.dart:11)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422025 | ConsoleHandler | INFO] #3      _RootAppState.initState (package:flobo/root_app.dart:53)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422073 | ConsoleHandler | INFO] #4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4355)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422117 | ConsoleHandler | INFO] #5      ComponentElement.mount (package:flutter/src/widgets/framework.dart:4201)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422160 | ConsoleHandler | INFO] #6      Element.inflateWidget (package:flutter/src/widgets/framework.dart:3194)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422216 | ConsoleHandler | INFO] #7      Element.updateChild (package:flutter/src/widgets/framework.dart:2988)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422259 | ConsoleHandler | INFO] #8      RenderObjectToWidgetElement._rebuild (package:flutter/src/widgets/binding.dart:1028)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422302 | ConsoleHandler | INFO] #9      RenderObjectToWidgetElement.mount (package:flutter/src/widgets/binding.dart:999)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422344 | ConsoleHandler | INFO] #10     RenderObjectToWidgetAdapter.attachToRenderTree.<anonymous closure> (package:flutter/src/widgets/binding.dart:942)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422388 | ConsoleHandler | INFO] #11     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2412)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422443 | ConsoleHandler | INFO] #12     RenderObjectToWidgetAdapter.attachToRenderTree (package:flutter/src/widgets/binding.dart:941)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422484 | ConsoleHandler | INFO] #13     WidgetsBinding.attachRootWidget (package:flutter/src/widgets/binding.dart:819)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422554 | ConsoleHandler | INFO] #14     WidgetsBinding.scheduleAttachRootWidget.<anonymous closure> (package:flutter/src/widgets/binding.dart:804)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422599 | ConsoleHandler | INFO] #15     _rootRun (dart:async/zone.dart:1122)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422656 | ConsoleHandler | INFO] #16     _CustomZone.run (dart:async/zone.dart:1023)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422699 | ConsoleHandler | INFO] #17     _CustomZone.runGuarded (dart:async/zone.dart:925)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422742 | ConsoleHandler | INFO] #18     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422786 | ConsoleHandler | INFO] #19     _rootRun (dart:async/zone.dart:1126)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422838 | ConsoleHandler | INFO] #20     _CustomZone.run (dart:async/zone.dart:1023)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422881 | ConsoleHandler | INFO] #21     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422927 | ConsoleHandler | INFO] #22     Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23)
03-09 22:54:53.422 23530 23559 I flutter : [2020-03-09 22:54:53.422969 | ConsoleHandler | INFO] #23     _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384)
03-09 22:54:53.423 23530 23559 I flutter : [2020-03-09 22:54:53.423023 | ConsoleHandler | INFO] #24     _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418)
03-09 22:54:53.423 23530 23559 I flutter : [2020-03-09 22:54:53.423069 | ConsoleHandler | INFO] #25     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174)
03-09 22:54:53.423 23530 23559 I flutter : [2020-03-09 22:54:53.423116 | ConsoleHandler | INFO] 
03-09 22:54:53.423 23530 23559 I flutter : [2020-03-09 22:54:53.423157 | ConsoleHandler | INFO] ======================================================================
@mhsmith
Copy link
Member

mhsmith commented Mar 10, 2020

The stack trace is incomplete, as it only includes the Dart stack trace, not the Java one. I'm sure there must be some way to configure Flutter to log that.

I don't know what Python libraries you're using, but when this message appears as a fatal exception it's usually because the program is trying to use the multiprocessing synchronization functions, which aren't available on Android. Some libraries attempt to check for this but catch the wrong exception type, in which case you might be able to find a workaround like #232 (comment).

@nimda1902
Copy link

we are using numpy, scikit-learn, pandas, joblib, tensorflow , keras. Unfortunately the workaround is not working with our case.

@nimda1902
Copy link

nimda1902 commented Mar 11, 2020

this is stack trace for Kotlin.

03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: com.chaquo.python.PyException: ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.multiprocessing.synchronize.<module>(synchronize.py:30)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.zipimport.load_module(<frozen zipimport>:259)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.java.chaquopy.import_override(import.pxi:60)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.joblib.externals.loky.backend.<module>(__init__.py:13)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.java.chaquopy.import_override(import.pxi:60)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.joblib.externals.loky.<module>(__init__.py:11)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.java.chaquopy.import_override(import.pxi:60)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.joblib.parallel.<module>(parallel.py:31)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.java.chaquopy.import_override(import.pxi:60)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.joblib.<module>(__init__.py:120)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.java.chaquopy.import_override(import.pxi:60)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.flobo.<module>(flobo.py:1)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:219)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:783)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:671)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:975)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:991)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1014)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.importlib.import_module(__init__.py:127)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModule(chaquopy_java.pyx:153)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at com.chaquo.python.Python.getModule(Native Method)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at org.mimos.flobo.MainActivity$onCreate$1.onMethodCall(Unknown Source:259)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(Unknown Source:17)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(Unknown Source:57)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(Unknown Source:4)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at android.os.MessageQueue.nativePollOnce(Native Method)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at android.os.MessageQueue.next(MessageQueue.java:363)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at android.os.Looper.loop(Looper.java:173)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at android.app.ActivityThread.main(ActivityThread.java:8178)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at java.lang.reflect.Method.invoke(Native Method)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
03-11 08:55:29.629  1956  1956 E MethodChannel#flobo_chaquopy: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

@mhsmith
Copy link
Member

mhsmith commented Mar 11, 2020

OK, you can probably work around this by using an older version of joblib: see #21 (comment).

@nimda1902
Copy link

yaaahhh... thanks mr @mhsmith , problem solved.

@mhsmith mhsmith closed this as completed Mar 11, 2020
@mhsmith
Copy link
Member

mhsmith commented Jul 28, 2020

If you're using Chaquopy 8.0.1 or later, there's no longer any need to use old versions of librosa or joblib.

To upgrade, edit your app's top-level build.gradle file and change the version number of com.chaquo.python:gradle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants