juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.15k stars 525 forks source link

App runs from flutter, but not when run from Xcode #758

Open dinonovak opened 1 year ago

dinonovak commented 1 year ago

Flutter 3.7.1 Unity 2022.2.1f1

When app is run from VS Code "Run without debugging" all works OK and Unity widget is initialised When running app from Xcode Unity widget is not initialised

Here is log from Xcode

`2023-02-03 20:09:05.717013+0100 Runner[39237:3666305] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)") 2023-02-03 20:09:05.717114+0100 Runner[39237:3666305] [SceneConfiguration] Info.plist contained no UIScene configuration dictionary (looking for configuration named "(no name)") 2023-02-03 20:09:05.950702+0100 Runner[39237:3666305] Metal API Validation Enabled 2023-02-03 20:09:06.210356+0100 Runner[39237:3666305] Built from '2022.2/release' branch, Version '2022.2.1f1 (4fead5835099)', Build type 'Release', Scripting Backend 'il2cpp' 2023-02-03 20:09:06.210906+0100 Runner[39237:3666305] MemoryManager: Using 'Default' Allocator. [UnityMemory] Configuration Parameters - Can be set up in boot.config "memorysetup-bucket-allocator-granularity=16" "memorysetup-bucket-allocator-bucket-count=8" "memorysetup-bucket-allocator-block-size=4194304" "memorysetup-bucket-allocator-block-count=1" "memorysetup-main-allocator-block-size=16777216" "memorysetup-thread-allocator-block-size=16777216" "memorysetup-gfx-main-allocator-block-size=16777216" "memorysetup-gfx-thread-allocator-block-size=16777216" "memorysetup-cache-allocator-block-size=4194304" "memorysetup-typetree-allocator-block-size=2097152" "memorysetup-profiler-bucket-allocator-granularity=16" "memorysetup-profiler-bucket-allocator-bucket-count=8" "memorysetup-profiler-bucket-allocator-block-size=4194304" "memorysetup-profiler-bucket-allocator-block-count=1" "memorysetup-profiler-allocator-block-size=16777216" "memorysetup-profiler-editor-allocator-block-size=1048576" "memorysetup-temp-allocator-size-main=4194304" "memorysetup-job-temp-allocator-block-size=2097152" "memorysetup-job-temp-allocator-block-size-background=1048576" "memorysetup-job-temp-allocator-reduction-small-platforms=262144" "memorysetup-temp-allocator-size-background-worker=32768" "memorysetup-temp-allocator-size-job-worker=262144" "memorysetup-temp-allocator-size-preload-manager=262144" "memorysetup-temp-allocator-size-nav-mesh-worker=65536" "memorysetup-temp-allocator-size-audio-worker=65536" "memorysetup-temp-allocator-size-cloud-worker=32768" "memorysetup-temp-allocator-size-gfx=262144" -> applicationDidFinishLaunching()

Setting UIViewControllerBasedStatusBarAppearance to NO is no longer supported. Apple actively discourages that, and all application-wide methods of changing status bar appearance are deprecated

-> applicationWillEnterForeground() -> applicationDidBecomeActive() [Subsystems] Discovering subsystems at path /private/var/containers/Bundle/Application/54459AF1-61C9-4D6A-9945-CA2CAB2D57F0/Runner.app/Frameworks/UnityFramework.framework/Data/UnitySubsystems [Subsystems] No descriptors matched for examples in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json. [Subsystems] 1 'inputs' descriptors matched in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json [Subsystems] No descriptors matched for displays in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json. [Subsystems] 1 'meshings' descriptors matched in UnitySubsystems/UnityARKit/UnitySubsystemsManifest.json GfxDevice: creating device client; threaded=1; jobified=0 Initializing Metal device caps: Apple A14 GPU Initialize engine version: 2022.2.1f1 (4fead5835099) The referenced script (Unknown) on this Behaviour is missing! The referenced script on this Behaviour (Game Object '') is missing! XRGeneral Settings awakening... UnityEngine.XR.Management.XRGeneralSettings:Awake()

2023-02-03 20:09:06.865336+0100 Runner[39237:3666305] // 2D joint skeleton enum JointIndices { Invalid = -1, Head = 0, // parent: Neck1 [1] Neck1 = 1, // parent: Root [16] RightShoulder1 = 2, // parent: Neck1 [1] RightForearm = 3, // parent: RightShoulder1 [2] RightHand = 4, // parent: RightForearm [3] LeftShoulder1 = 5, // parent: Neck1 [1] LeftForearm = 6, // parent: LeftShoulder1 [5] LeftHand = 7, // parent: LeftForearm [6] RightUpLeg = 8, // parent: Root [16] RightLeg = 9, // parent: RightUpLeg [8] RightFoot = 10, // parent: RightLeg [9] LeftUpLeg = 11, // parent: Root [16] LeftLeg = 12, // parent: LeftUpLeg [11] LeftFoot = 13, // parent: LeftLeg [12] RightEye = 14, // parent: Head [0] LeftEye = 15, // parent: Head [0] Root = 16, // parent: [-1] RightEar = 17, // parent: RightEye [14] LeftEar = 18, // parent: LeftEye [15] } 2023-02-03 20:09:06.873276+0100 Runner[39237:3666305] // 3D joint skeleton enum JointIndices { Invalid = -1, Root = 0, // parent: [-1] Hips = 1, // parent: Root [0] LeftUpLeg = 2, // parent: Hips [1] LeftLeg = 3, // parent: LeftUpLeg [2] LeftFoot = 4, // parent: LeftLeg [3] LeftToes = 5, // parent: LeftFoot [4] LeftToesEnd = 6, // parent: LeftToes [5] RightUpLeg = 7, // parent: Hips [1] RightLeg = 8, // parent: RightUpLeg [7] RightFoot = 9, // parent: RightLeg [8] RightToes = 10, // parent: RightFoot [9] RightToesEnd = 11, // parent: RightToes [10] Spine1 = 12, // parent: Hips [1] Spine2 = 13, // parent: Spine1 [12] Spine3 = 14, // parent: Spine2 [13] Spine4 = 15, // parent: Spine3 [14] Spine5 = 16, // parent: Spine4 [15] Spine6 = 17, // parent: Spine5 [16] Spine7 = 18, // parent: Spine6 [17] LeftShoulder1 = 19, // parent: Spine7 [18] LeftArm = 20, // parent: LeftShoulder1 [19] LeftForearm = 21, // parent: LeftArm [20] LeftHand = 22, // parent: LeftForearm [21] LeftHandIndexStart = 23, // parent: LeftHand [22] LeftHandIndex1 = 24, // parent: LeftHandIndexStart [23] LeftHandIndex2 = 25, // parent: LeftHandIndex1 [24] LeftHandIndex3 = 26, // parent: LeftHandIndex2 [25] LeftHandIndexEnd = 27, // parent: LeftHandIndex3 [26] LeftHandMidStart = 28, // parent: LeftHand [22] LeftHandMid1 = 29, // parent: LeftHandMidStart [28] LeftHandMid2 = 30, // parent: LeftHandMid1 [29] LeftHandMid3 = 31, // parent: LeftHandMid2 [30] LeftHandMidEnd = 32, // parent: LeftHandMid3 [31] LeftHandPinkyStart = 33, // parent: LeftHand [22] LeftHandPinky1 = 34, // parent: LeftHandPinkyStart [33] LeftHandPinky2 = 35, // parent: LeftHandPinky1 [34] LeftHandPinky3 = 36, // parent: LeftHandPinky2 [35] LeftHandPinkyEnd = 37, // parent: LeftHandPinky3 [36] LeftHandRingStart = 38, // parent: LeftHand [22] LeftHandRing1 = 39, // parent: LeftHandRingStart [38] LeftHandRing2 = 40, // parent: LeftHandRing1 [39] LeftHandRing3 = 41, // parent: LeftHandRing2 [40] LeftHandRingEnd = 42, // parent: LeftHandRing3 [41] LeftHandThumbStart = 43, // parent: LeftHand [22] LeftHandThumb1 = 44, // parent: LeftHandThumbStart [43] LeftHandThumb2 = 45, // parent: LeftHandThumb1 [44] LeftHandThumbEnd = 46, // parent: LeftHandThumb2 [45] Neck1 = 47, // parent: Spine7 [18] Neck2 = 48, // parent: Neck1 [47] Neck3 = 49, // parent: Neck2 [48] Neck4 = 50, // parent: Neck3 [49] Head = 51, // parent: Neck4 [50] Jaw = 52, // parent: Head [51] Chin = 53, // parent: Jaw [52] LeftEye = 54, // parent: Head [51] LeftEyeLowerLid = 55, // parent: LeftEye [54] LeftEyeUpperLid = 56, // parent: LeftEye [54] LeftEyeball = 57, // parent: LeftEye [54] Nose = 58, // parent: Head [51] RightEye = 59, // parent: Head [51] RightEyeLowerLid = 60, // parent: RightEye [59] RightEyeUpperLid = 61, // parent: RightEye [59] RightEyeball = 62, // parent: RightEye [59] RightShoulder1 = 63, // parent: Spine7 [18] RightArm = 64, // parent: RightShoulder1 [63] RightForearm = 65, // parent: RightArm [64] RightHand = 66, // parent: RightForearm [65] RightHandIndexStart = 67, // parent: RightHand [66] RightHandIndex1 = 68, // parent: RightHandIndexStart [67] RightHandIndex2 = 69, // parent: RightHandIndex1 [68] RightHandIndex3 = 70, // parent: RightHandIndex2 [69] RightHandIndexEnd = 71, // parent: RightHandIndex3 [70] RightHandMidStart = 72, // parent: RightHand [66] RightHandMid1 = 73, // parent: RightHandMidStart [72] RightHandMid2 = 74, // parent: RightHandMid1 [73] RightHandMid3 = 75, // parent: RightHandMid2 [74] RightHandMidEnd = 76, // parent: RightHandMid3 [75] RightHandPinkyStart = 77, // parent: RightHand [66] RightHandPinky1 = 78, // parent: RightHandPinkyStart [77] RightHandPinky2 = 79, // parent: RightHandPinky1 [78] RightHandPinky3 = 80, // parent: RightHandPinky2 [79] RightHandPinkyEnd = 81, // parent: RightHandPinky3 [80] RightHandRingStart = 82, // parent: RightHand [66] RightHandRing1 = 83, // parent: RightHandRingStart [82] RightHandRing2 = 84, // parent: RightHandRing1 [83] RightHandRing3 = 85, // parent: RightHandRing2 [84] RightHandRingEnd = 86, // parent: RightHandRing3 [85] RightHandThumbStart = 87, // parent: RightHand [66] RightHandThumb1 = 88, // parent: RightHandThumbStart [87] RightHandThumb2 = 89, // parent: RightHandThumb1 [88] RightHandThumbEnd = 90, // parent: RightHandThumb2 [89] } [Subsystems] Loading plugin UnityARKit for subsystem ARKit-Input... [Subsystems] UnityARKit successfully registered Provider for ARKit-Input [Subsystems] UnityARKit successfully registered Provider for ARKit-Input [Subsystems] UnityARKit successfully registered Provider for ARKit-Meshing [Subsystems] Loading plugin UnityARKit for subsystem ARKit-Meshing... New input system (experimental) initialized 2023-02-03 20:09:06.892348+0100 Runner[39237:3666305] [Window] Manually adding the rootViewController's view to the view hierarchy is no longer supported. Please allow UIWindow to add the rootViewController's view to the view hierarchy itself. 2023-02-03 20:09:06.933962+0100 Runner[39237:3666305] Unbalanced calls to begin/end appearance transitions for <SplashScreenController: 0x10db8b910>. 2023-02-03 20:09:06.934556+0100 Runner[39237:3666305] Unbalanced calls to begin/end appearance transitions for <UnityDefaultViewController: 0x10db8b120>. UnloadTime: 2.391667 ms NullReferenceException: Object reference not set to an instance of an object. at PlacementIndicatorScript.Update () [0x00000] in <00000000000000000000000000000000>:0

2023-02-03 20:09:09.038191+0100 Runner[39237:3666305] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x282385900 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x283c23200 imageResolution=(1920, 1440) pixelFormat=(420f) framesPerSecond=(60) captureDeviceType=AVCaptureDeviceTypeBuiltInWideAngleCamera captureDevicePosition=(1)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None appClipCodeTracking=Disabled> 2023-02-03 20:09:09.039827+0100 Runner[39237:3666305] UnityARKit: Updating ARSession configuration with <ARWorldTrackingConfiguration: 0x282394900 worldAlignment=Gravity lightEstimation=Disabled frameSemantics=None videoFormat=<ARVideoFormat: 0x283c23200 imageResolution=(1920, 1440) pixelFormat=(420f) framesPerSecond=(60) captureDeviceType=AVCaptureDeviceTypeBuiltInWideAngleCamera captureDevicePosition=(1)> autoFocus=Enabled environmentTexturing=None wantsHDREnvironmentTextures=Enabled planeDetection=Horizontal collaboration=Disabled userFaceTracking=Disabled sceneReconstruction=None appClipCodeTracking=Disabled> `

timbotimbo commented 1 year ago

Can you try to disable the Xcode thread performance checker as described here?

dinonovak commented 1 year ago

Performance checker disabled.

Finally this adjustment in controller startup solved the problem:

void onUnityCreated(controller) { _unityWidgetController = controller; _unityWidgetController.pause(); Future.delayed(Duration(seconds: 1), () { _unityWidgetController.resume(); }); }

halfspacer commented 1 year ago

Super weird, the pause, wait and resume solved the issue for me too. Widget just wouldn't initialize.

timbotimbo commented 1 year ago

For anyone where the pause + resume trick seems to fix the issue: Can you try the unityready fix from pull request #747?

I'm not 100% sure it is related, but having a "ready" trigger never happen could certainly cause something like this.

alexandrefresnais commented 1 year ago

Hi,

Just had the issue on a fresh project and the wait and resume trick solved the issue for me too. The pull request you mentioned has been merged since and doesn't seem to solve the issue.

I am on Unity 2022.2.6f1, working with an iPhone13 and Xcode 14.3.1. Thread performance checker is disabled.