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

[BUG] Unhandled Exception: Null check operator used on a null value at agora_uikit/controllers/session_controller.dart:217. #46

Closed
agent515 opened this issue Sep 22, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@agent515
Copy link

Describe the bug
After running the code given below, the connectionData property of value (Session Value Notifier) is returning null and throwing Null Exception that is not being handled. This is preventing AgoraClient from initializing the RtcEngine.

I tried almost the same code on another app for testing purposes and it worked fine.

To Reproduce

video_call_screen.dart

import 'package:agora_uikit/agora_uikit.dart';
import 'package:flutter/material.dart';

class VideoCallScreen extends StatefulWidget {
  const VideoCallScreen({Key? key, required this.channelName})
      : super(key: key);

  final String channelName;
  @override
  _VideoCallScreenState createState() => _VideoCallScreenState();
}

class _VideoCallScreenState extends State<VideoCallScreen> {
  late final AgoraClient _client;

  @override
  void initState() {
    super.initState();
    _client = AgoraClient(
      agoraConnectionData: AgoraConnectionData(
        appId: String.fromEnvironment('AGORA_APP_ID'),
        channelName: 'aezakm',
        tempToken:
            "006bfd956b99d2e4df58d25530fd3bc2422IADWEccVGBqRNMdELkl1Ouex0Tp+89moeeAOGCrNFgSctgfLJdsAAAAAIgD5r/DT6lJMYQQAAQB6D0thAgB6D0thAwB6D0thBAB6D0th",
      ),
      enabledPermission: [
        Permission.camera,
        Permission.microphone,
      ],
      agoraEventHandlers: AgoraEventHandlers(
          leaveChannel: (stats) {
            Navigator.pop(context);
          },
          userJoined: (uid, _) {
            print('$uid joined');
          },
          remoteAudioStateChanged: (uid, _, __, ___) {},
          onError: (error) {
            print(error);
          },
          activeSpeaker: (uid) {},
          userOffline: (uid, reason) {
            print('$uid left because of $reason');
          },
          tokenPrivilegeWillExpire: (val) {
            print("token is expiring");
          },
          localAudioStateChanged: (_, __) {},
          remoteVideoStateChanged: (uid, _, __, ___) {},
          localVideoStateChanged: (uid, _) {},
          joinChannelSuccess: (channel, uid, __) {
            print('$uid joined $channel successfully.');
          }),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Stack(
          children: [
            AgoraVideoViewer(client: _client),
            AgoraVideoButtons(client: _client),
          ],
        ),
      ),
    );
  }
}

I am using a function in a ChangeNotifierProvider to navigate to the video_call_screen

video_call_provider.dart

Future<void> joinVideo(
    BuildContext context, {
    required String channelName,
  }) async {
    Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => VideoCallScreen(
          channelName: channelName,
        ),
      ),
    );
  }

Expected behavior
RtcEngine should be initialized with no problem and the video should be visible.

Screenshots
image

black screen with control buttons

**Smartphone (please complete the following information):** - Device: Pixel 3 API 29 - OS: Pie - Browser: Chrome

Additional context

I/chatty  ( 7583): uid=10167(com.wolfpak) 1.ui identical 1 line
I/flutter ( 7583): Role.Student
I/flutter ( 7583): Error occured while initializing Agora RtcEngine: PlatformException(7, not initialized, null, null)
W/Gralloc3( 7583): allocator 3.x is not supported
I/com.wolfpak( 7583): NativeAlloc concurrent copying GC freed 2997(352KB) AllocSpace objects, 0(0B) LOS objects, 49% free, 2404KB/4809KB, paused 247us total 193.547ms
D/HostConnection( 7583): HostConnection::get() New Host Connection established 0xde34c870, tid 7708
D/HostConnection( 7583): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_gles_max_version_2
D/eglCodecCommon( 7583): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation( 7583): eglCreateContext: 0xde31afc0: maj 2 min 0 rcv 2
D/EGL_emulation( 7583): eglMakeCurrent: 0xdacf4860: ver 2 0 (tinfo 0xf1689a10)
D/EGL_emulation( 7583): eglMakeCurrent: 0xde31afc0: ver 2 0 (tinfo 0xbf43dce0)
E/EGL_emulation( 7583): eglQueryContext 32c0  EGL_BAD_ATTRIBUTE
E/EGL_emulation( 7583): tid 7708: eglQueryContext(1902): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/AGORA_SDK( 7583): Surface changed to width 1080 height 2022
E/flutter ( 7583): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
E/flutter ( 7583): #0      SessionController.joinVideoChannel
package:agora_uikit/controllers/session_controller.dart:217
E/flutter ( 7583): <asynchronous suspension>
E/flutter ( 7583): #1      AgoraClient._initAgoraRtcEngine
package:agora_uikit/src/agora_client.dart:68
E/flutter ( 7583): <asynchronous suspension>
E/flutter ( 7583):
@agent515 agent515 added the bug Something isn't working label Sep 22, 2021
@Meherdeep
Copy link
Contributor

@agent515 Thanks for reporting this. We are currently working on fixing this.

@Meherdeep
Copy link
Contributor

@agent515 This error has been fixed, please try it out and let us know.

@Meherdeep
Copy link
Contributor

@agent515 Closing this issue for now. Feel free to open it again if you're still facing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants