flutter-webrtc / dart-sip-ua

A dart-lang version of the SIP UA stack.
MIT License
339 stars 270 forks source link

Registration works on debug, not on release #420

Open henwhy opened 10 months ago

henwhy commented 10 months ago

Building a VOIP application on Flutter to connect to Freeswitch server webrtc, and loading registration information from Firestore. Problem Android: Registration works ok in debug mode, but when I move to either packaging the application to appbundle and releasing it to be downloaded OR straight running the application in --release mode prevents the registration.

I've tried to set information to UaSettings manually without fetching them from firestore and gone as far as to having the user to manually flip a switch to do the registration. Nothing seems to work and the error code remains:

E/flutter (28324): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (length): Invalid value: Only valid value is 0: 1 E/flutter (28324): #0 JFa._bYe (wMg) E/flutter (28324): #1 JFa.HPb (wMg:89) E/flutter (28324): #2 new bFa (gMg:13) E/flutter (28324): #3 BHe (gMg:7) E/flutter (28324): #4 new WFa (IMg) E/flutter (28324): #5 wFa.start (uMg:123) E/flutter (28324): #6 Kt.register (owg:89) E/flutter (28324): E/flutter (28324):

I tried to set the information wrong to see if it's the information it's fetching and the error code was just longer but the initial one remains still the same "Unhandled Exception: RangeError (length): Invalid value: Only valid value is 0: 1"

Installed the package, Set the package accordingly to GitHub example and it works fine on debug flutter run --release or building to appbundle and releasing it play console E/flutter (28324): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (length): Invalid value: Only valid value is 0: 1 E/flutter (28324): #0 JFa._bYe (wMg) E/flutter (28324): #1 JFa.HPb (wMg:89) E/flutter (28324): #2 new bFa (gMg:13) E/flutter (28324): #3 BHe (gMg:7) E/flutter (28324): #4 new WFa (IMg) E/flutter (28324): #5 wFa.start (uMg:123) E/flutter (28324): #6 Kt.register (owg:89) E/flutter (28324): E/flutter (28324):

I expected sip_ua-registration and functionalities to work the same way in debug and release of the version.

Flutter 3.19.0-4.0.pre.29 targetSdkVersion 34 minSdkVersion 29 macOS Sonoma 14.2.1 Testing made with Nokia X30 5G Android 13

victortive commented 3 months ago

It looks like your classes are minified. Are you using proguard on Android? Make sure the compiler did not compile out the necessary classes. Check the README for progaurd setup

# proguard-rules.pro 
-keep class com.cloudwebrtc.webrtc.** {*;}
-keep class org.webrtc.** {*;}
henwhy commented 3 months ago

It looks like your classes are minified. Are you using proguard on Android? Make sure the compiler did not compile out the necessary classes. Check the README for progaurd setup

# proguard-rules.pro 
-keep class com.cloudwebrtc.webrtc.** {*;}
-keep class org.webrtc.** {*;}

My proguard is exactly as taken from the pub dev sip_ua page:

-keep class io.flutter.app. { *; } -keep class io.flutter.plugin.* { ; } -keep class io.flutter.util. { *; } -keep class io.flutter.view. { *; } -keep class io.flutter.* { ; } -keep class io.flutter.plugins. { *; }

-keep class com.cloudwebrtc.webrtc.* {;} -keep class org.webrtc.* {;}

I've tried minifyEnabled false where it shouldn't matter if I used pro guard or not but the result stays the same with obsfucated range error which I cannot resolve. Works totally fine on debug but with the examples I cannot seem to get it working on flutter run --release. I checked the outputs at mapping.txt which should give out some indication on whether or not the pro guard is applied and I could find clues that webrtc is indeed included. A while back I had some luck with registering for iPhone so I think it has something to do with Android rules or something. Any other suggestions?

victortive commented 3 months ago

Try removing

-keep class io.flutter.app.** { ; }
-keep class io.flutter.plugin.* { ; }
-keep class io.flutter.util.* { ; }
-keep class io.flutter.view.* { ; }
-keep class io.flutter.* { ; }
-keep class io.flutter.plugins.* { *; }
henwhy commented 2 months ago

Try removing

-keep class io.flutter.app.** { ; }
-keep class io.flutter.plugin.* { ; }
-keep class io.flutter.util.* { ; }
-keep class io.flutter.view.* { ; }
-keep class io.flutter.* { ; }
-keep class io.flutter.plugins.* { *; }

Tried removing the mentioned snippet from pro guard file but it still keeps me from registering on flutter run --release. I'm stumped as to shouldn't the pro guard file matter only if minifyEnabled is true? Therefore I think it has less to do with the proguard and more to do with something the application requires in order to get the chance to register when the mode is on release rather than debug.

Artemshchurev commented 1 month ago

@henwhy any news here? I have the same problem.

henwhy commented 1 week ago

@Artemshchurev Still no news. I forked the example app from GitHub and sandboxed. Flutter run --debug and flutter run --profile works and the registration is ok on our end and on the front end. Flutter run --release does absolutely nothing in the example app using login information to our server, it feels like the whole registration button is just null on release. Awaiting a solution so that the plugin could be used in release version.

Any news on your end? I've noticed that you've made a similar post on the shortcomings of --release version. I checked your solution and you're saying that it works with --release?