Search Unity

Resolved Voice SDK crash on Activate (Meta Quest 3)

Discussion in 'VR' started by tststs, Dec 9, 2023.

  1. tststs

    tststs

    Joined:
    Jul 16, 2016
    Posts:
    11
    Hey,

    trying to add the Voice SDK in my project.

    * Unity 2023.2.2
    * Voice SDK

    I'm using the exampe script named VoiceActivationButton:

    Code (CSharp):
    1. /*
    2. * Copyright (c) Meta Platforms, Inc. and affiliates.
    3. * All rights reserved.
    4. *
    5. * Licensed under the Oculus SDK License Agreement (the "License");
    6. * you may not use the Oculus SDK except in compliance with the License,
    7. * which is provided at the time of installation or download, or which
    8. * otherwise accompanies this software in either electronic or hard copy form.
    9. *
    10. * You may obtain a copy of the License at
    11. *
    12. * https://developer.oculus.com/licenses/oculussdk/
    13. *
    14. * Unless required by applicable law or agreed to in writing, the Oculus SDK
    15. * distributed under the License is distributed on an "AS IS" BASIS,
    16. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    17. * See the License for the specific language governing permissions and
    18. * limitations under the License.
    19. */
    20.  
    21. using Meta.WitAi;
    22. using Meta.WitAi.Requests;
    23. using UnityEngine;
    24. using UnityEngine.UI;
    25.  
    26. namespace Taikonauten.Conduit.UX
    27. {
    28.     [RequireComponent(typeof(Button))]
    29.     public class VoiceActivationButton : MonoBehaviour
    30.     {
    31.         // The button to be observed
    32.         private Button _button;
    33.         // The button label to be adjusted with state
    34.         private Text _buttonLabel;
    35.  
    36.         [Tooltip("Reference to the current voice service")]
    37.         [SerializeField] private VoiceService _voiceService;
    38.  
    39.         [Tooltip("Text to be shown while the voice service is not active")]
    40.         [SerializeField] private string _activateText = "Activate";
    41.         [Tooltip("Whether to immediately send data to service or to wait for the audio threshold")]
    42.         [SerializeField] private bool _activateImmediately = false;
    43.  
    44.         [Tooltip("Text to be shown while the voice service is active")]
    45.         [SerializeField] private string _deactivateText = "Deactivate";
    46.         [Tooltip("Whether to immediately abort request activation on deactivate")]
    47.         [SerializeField] private bool _deactivateAndAbort = false;
    48.  
    49.         // Current request
    50.         private VoiceServiceRequest _request;
    51.         private bool _isActive = false;
    52.  
    53.         // Get button & label
    54.         private void Awake()
    55.         {
    56.             _buttonLabel = GetComponentInChildren<Text>();
    57.             _button = GetComponent<Button>();
    58.             if (_voiceService == null)
    59.             {
    60.                 _voiceService = FindObjectOfType<VoiceService>();
    61.             }
    62.         }
    63.         // Add click delegate
    64.         private void OnEnable()
    65.         {
    66.             RefreshActive();
    67.             if (_button != null)
    68.             {
    69.                 _button.onClick.AddListener(OnClick);
    70.             }
    71.         }
    72.         // Remove click delegate
    73.         private void OnDisable()
    74.         {
    75.             _isActive = false;
    76.             if (_button != null)
    77.             {
    78.                 _button.onClick.RemoveListener(OnClick);
    79.             }
    80.         }
    81.  
    82.         // On click, activate if not active & deactivate if active
    83.         private void OnClick()
    84.         {
    85.             if (!_isActive)
    86.             {
    87.                 Activate();
    88.             }
    89.             else
    90.             {
    91.                 Deactivate();
    92.             }
    93.         }
    94.  
    95.         // Activate depending on settings
    96.         private void Activate()
    97.         {
    98.             if (!_activateImmediately)
    99.             {
    100.                 _request = _voiceService.Activate(GetRequestEvents());
    101.             }
    102.             else
    103.             {
    104.                 _request = _voiceService.ActivateImmediately(GetRequestEvents());
    105.             }
    106.         }
    107.  
    108.         // Deactivate depending on settings
    109.         private void Deactivate()
    110.         {
    111.             if (!_deactivateAndAbort)
    112.             {
    113.                 _request.DeactivateAudio();
    114.             }
    115.             else
    116.             {
    117.                 _request.Cancel();
    118.             }
    119.         }
    120.  
    121.         // Get events
    122.         private VoiceServiceRequestEvents GetRequestEvents()
    123.         {
    124.             VoiceServiceRequestEvents events = new VoiceServiceRequestEvents();
    125.             events.OnInit.AddListener(OnInit);
    126.             events.OnComplete.AddListener(OnComplete);
    127.             return events;
    128.         }
    129.         // Request initialized
    130.         private void OnInit(VoiceServiceRequest request)
    131.         {
    132.             _isActive = true;
    133.             RefreshActive();
    134.         }
    135.         // Request completed
    136.         private void OnComplete(VoiceServiceRequest request)
    137.         {
    138.             _isActive = false;
    139.             RefreshActive();
    140.         }
    141.  
    142.         // Refresh active text
    143.         private void RefreshActive()
    144.         {
    145.             if (_buttonLabel != null)
    146.             {
    147.                 _buttonLabel.text = _isActive ? _deactivateText : _activateText;
    148.             }
    149.         }
    150.     }
    151. }
    152.  
    As soon i press the button in an Android build the following happens:
    An suggestions?

    Code (CSharp):
    1.  
    2. 2023/12/09 09:49:15.841 25324 25349 Info Unity Taikonauten.Conduit.UX.VoiceActivationButton:Activate()
    3. 2023/12/09 09:49:15.841 25324 25349 Info Unity UnityEngine.Events.UnityEvent:Invoke()
    4. 2023/12/09 09:49:15.841 25324 25349 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    5. 2023/12/09 09:49:15.841 25324 25349 Info Unity UnityEngine.XR.Interaction.Toolkit.UI.UIInputModule:ProcessPointerButton(ButtonDeltaState, PointerEventData)
    6. 2023/12/09 09:49:15.841 25324 25349 Info Unity UnityEngine.XR.Interaction.Toolkit.UI.UIInputModule:ProcessTrackedDevice(TrackedDeviceModel&, Boolean)
    7. 2023/12/09 09:49:15.841 25324 25349 Info Unity UnityEngine.XR.Interaction.Toolkit.UI.XRUIInputModule:DoProcess()
    8. 2023/12/09 09:49:15.841 25324 25349 Info Unity
    9. 2023/12/09 09:49:15.850 25324 25349 Error Unity AndroidJavaException: java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference
    10. 2023/12/09 09:49:15.850 25324 25349 Error Unity java.lang.NullPointerException: Attempt to read from field 'android.os.MessageQueue android.os.Looper.mQueue' on a null object reference
    11. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at android.os.Handler.<init>(Handler.java:257)
    12. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at android.os.Handler.<init>(Handler.java:162)
    13. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at com.oculus.assistant.api.voicesdk.core.VoiceSDKConnection$1.<init>(VoiceSDKConnection.java:54)
    14. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at com.oculus.assistant.api.voicesdk.core.VoiceSDKConnection.<init>(VoiceSDKConnection.java:54)
    15. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at com.oculus.assistant.api.voicesdk.logging.PlatformLogger$2.<init>(PlatformLogger.java:57)
    16. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at com.oculus.assistant.api.voicesdk.logging.PlatformLogger.<init>(PlatformLogger.java:56)
    17. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at com.oculus.assistant.api.unity.logging.UnityPlatformLoggerServiceFragment.createAndAttach(UnityPlatformLoggerServiceFragment.java:53)
    18. 2023/12/09 09:49:15.850 25324 25349 Error Unity     at com.oculus.assistant.api.unity.logging.UnityPlatformLoggerServiceFragment.createAndAttach(UnityPlatformLogg
    19.  
    Thanks!
     
  2. tststs

    tststs

    Joined:
    Jul 16, 2016
    Posts:
    11
    Ok found the issue.

    * Set Android target API 12L
    * Use custom Manifest under Publishing settings
    * Switch to Player Activity instead of Game Activity
     
    Last edited: Dec 9, 2023
  3. Deltigre

    Deltigre

    Unity Technologies

    Joined:
    Sep 13, 2022
    Posts:
    36
    Glad you fixed the issue - it seems like you're using a third-party package provided by Taikonauten - I would recommend contacting them if you have further issues.