Closed FaizanAhmad127 closed 1 year ago
same here
@FaizanAhmad127 Can you share the more stack trace of the error log?
Having the same issue here. It's working fine after one call, this exception is throwing only on the first initialization for me.
[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field 'requestPort' has not been initialized.
#0 _ApiCallExecutor.requestPort (package:agora_rtc_engine/src/impl/api_caller.dart)
#1 _ApiCallExecutor.callIrisApiWithUin8ListAsync (package:agora_rtc_engine/src/impl/api_caller.dart:273:5)
#2 ApiCaller.callIrisApiWithUin8ListAsync (package:agora_rtc_engine/src/impl/api_caller.dart:110:10)
#3 ApiCaller.callIrisApi (package:agora_rtc_engine/src/impl/api_caller.dart:118:12)
#4 RtcEngineImpl.enableAudio (package:agora_rtc_engine/src/binding/agora_rtc_engine_impl.dart:723:25)
#9 AgoraRtmChannel._eventListener (package:agora_rtm/src/agora_rtm_channel.dart:60:33)
#10 _RootZone.runUnaryGuarded (dart:async/zone.dart:1586:10)
#11 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
#12 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
#13 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
#14 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:591:7)
#15 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#16 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
@FaizanAhmad127 Can you share the more stack trace of the error log?
E/flutter (10089): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field 'requestPort' has not been initialized.
E/flutter (10089): #0 _ApiCallExecutor.requestPort (package:agora_rtc_engine/src/impl/api_caller.dart)
package:agora_rtc_engine/…/impl/api_caller.dart:1
E/flutter (10089): #1 _ApiCallExecutor.callIrisApiWithUin8ListAsync
package:agora_rtc_engine/…/impl/api_caller.dart:273
E/flutter (10089): #2 ApiCaller.callIrisApiWithUin8ListAsync
package:agora_rtc_engine/…/impl/api_caller.dart:110
E/flutter (10089): #3 ApiCaller.callIrisApi
package:agora_rtc_engine/…/impl/api_caller.dart:118
E/flutter (10089): #4 RtcEngineImpl.setupLocalVideo
package:agora_rtc_engine/…/binding/agora_rtc_engine_impl.dart:706
E/flutter (10089): #5 VideoViewControllerBaseMixin.setupView
package:agora_rtc_engine/…/impl/video_view_controller_impl.dart:125
E/flutter (10089): #6 _AgoraRtcRenderPlatformViewState._setupVideo
package:agora_rtc_engine/…/impl/agora_video_view_impl.dart:111
E/flutter (10089): <asynchronous suspension>
I think the method createAgoraRtcEngine()
should be async just like in previous versions we had await RtcEngine.create(appID)
. When the app gets big then it only gives the error else it's fine.
Solved. I created a service class in which I put this piece of code
class Foo
{
late RtcEngine engine;
Foo()
{
engine = createAgoraRtcEngine();
engine.initialize(RtcEngineContext(
appId: 'your_app_id',
logConfig: LogConfig(level: LogLevel.logLevelError)));
}
}
and used get it package to achieve a singleton pattern which is also suggested by Agora while creating RTCEngine so we can have only one instance of it. And then register the service class at the very beginning of main() like this:
GetIt locator = GetIt.instance;
locator.registerLazySingleton(() => Foo()); //Foo should be replace by your service class
Then I used the engine variable inside my video call screen,like this
final foo=locator.get<Foo>();
RtcEngine engine=foo.engine;
and the rest of the code remains the same. I don't really get the depth of the issue. A proper solution must be provided.
You should call the RtcEngine
APIs after initialize
, cause the initialize
is async function, so you need check the initialized state:
class VideoCallPageState extends State<VideoCallPage> {
late RtcEngine _engine;
bool _isInitialized = false;
@override
void initState() {
super.initState();
// initialize agora sdk
initialize();
}
Future<void> initialize() async {
_engine = createAgoraRtcEngine();
await _engine.initialize(RtcEngineContext(
appId: 'your_app_id',
logConfig: LogConfig(level: LogLevel.logLevelError)));
setState((){
_isInitialized = true;
});
}
@override
Widget build(BuildContext context) {
if (!_isInitialized) {
return Container();
}
// Only show AgoraVideoView after initialized
...
}
}
Thanks, yes I know that and I was doing the exact same thing but it led me to a response port error in my large-scale project. I'm doing the same now but in a service class that is run before other service classes. If I run your code after other services it gives me an error, which means I have to create and initialize the engine before everything else in my app.
This can be enhanced, but you should control the initializing order on your own at this time.
Yes, I have done that. But any luck on finding why we get responsePort error?
Since the responsePort
is initiated in the RtcEngine.initialize
function, if any APIs are called before RtcEngine.initialize
will be caused this error.
i'm facing the same problem. if you can fix, let me know. thanks man
@littleGnAl iam getting the same error and the same steps to reproduce it. If initialization is the case, then it should give the error in the first call also.
Please same here, after upgrading my Flutter today, [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: LateInitializationError: Field 'deviceName' has not been initialized.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please raise a new issue.
I am working on a large-scale project and integrating video calls into it. So I made a separate project just for practice and I achieved good results. The group calling worked perfectly on both android and IOS. But then I integrated the same code in my large-scale project which uses firebase as a backend and when I navigate to the video screen it gives me an error saying "Unhandled Exception: LateInitializationError: Field 'requestPort' has not been initialized". The Agora console is on Testing for now and the channel wasn't expired just in case you guys are wondering. As I said it works perfectly in a separate project.
The app uses agora_rtc_engine: ^6.1.0 and defined in pubspec.yaml file