我正在将一个简单的构建从 Unity 部署到 HoloLens 2。
我正在使用 Unity 2021.3.36f1 和 VS 2019。
我使用的软件包是:
我一直在关注 Microsoft 在此链接上提供的 HoloLens 2 基础教程。每当我将构建部署到 HoloLens 2 时,我都会收到以下错误:
MRTK 04.01.exe 中 0x00007FFBD28B8480 (GameAssembly.dll) 处未处理的异常:0xC00000FD:堆栈溢出(参数:0x0000000000000001、0x000000D26BF03D60)。
在下面的代码块中键入
<<<ERROR>>>
时会生成错误。
# if defined(ASM_CLEAR_CODE)
void *GC_clear_stack_inner(void *, ptr_t);
# else
/* Clear the stack up to about limit. Return arg. This function */
/* is not static because it could also be erroneously defined in .S */
/* file, so this error would be caught by the linker. */
void *GC_clear_stack_inner(void *arg,
# if defined(__APPLE_CC__) && !GC_CLANG_PREREQ(6, 0)
volatile /* to workaround some bug */
# endif
ptr_t limit)
{ <<<ERROR>>>
# define CLEAR_SIZE 213 /* granularity */
volatile word dummy[CLEAR_SIZE];
BZERO((/* no volatile */ void *)dummy, sizeof(dummy));
if ((word)GC_approx_sp() COOLER_THAN (word)limit) {
(void)GC_clear_stack_inner(arg, limit);
}
/* Make sure the recursive call is not a tail call, and the bzero */
/* call is not recognized as dead code. */
GC_noop1((word)dummy);
return(arg);
}
# endif /* !ASM_CLEAR_CODE */
从
misc.c
开始的 1450 到 1510 行粘贴在下面:
1450 static GC_bool getWinRTLogPath(wchar_t* buf, size_t bufLen)
1451 {
1452 static const GUID kIID_IApplicationDataStatics = {
1453 0x5612147B, 0xE843, 0x45E3,
1454 0x94, 0xD8, 0x06, 0x16, 0x9E, 0x3C, 0x8E, 0x17
1455 };
1456 static const GUID kIID_IStorageItem = {
1457 0x4207A996, 0xCA2F, 0x42F7,
1458 0xBD, 0xE8, 0x8B, 0x10, 0x45, 0x7A, 0x7F, 0x30
1459 };
1460 GC_bool result = FALSE;
1461 HSTRING_HEADER appDataClassNameHeader;
1462 HSTRING appDataClassName;
1463 __x_ABI_CWindows_CStorage_CIApplicationDataStatics* appDataStatics = 0;
1464
1465 GC_ASSERT(bufLen > 0);
1466 if (SUCCEEDED(WindowsCreateStringReference(
1467 RuntimeClass_Windows_Storage_ApplicationData,
1468 (sizeof(RuntimeClass_Windows_Storage_ApplicationData)-1)
1469 / sizeof(wchar_t),
1470 &appDataClassNameHeader, &appDataClassName))
1471 && SUCCEEDED(RoGetActivationFactory(appDataClassName,
1472 &kIID_IApplicationDataStatics,
1473 &appDataStatics))) {
1474 __x_ABI_CWindows_CStorage_CIApplicationData* appData = NULL;
1475 __x_ABI_CWindows_CStorage_CIStorageFolder* tempFolder = NULL;
1476 __x_ABI_CWindows_CStorage_CIStorageItem* tempFolderItem = NULL;
1477 HSTRING tempPath = NULL;
1478
1479 if (SUCCEEDED(appDataStatics->lpVtbl->get_Current(appDataStatics,
1480 &appData))
1481 && SUCCEEDED(appData->lpVtbl->get_TemporaryFolder(appData,
1482 &tempFolder))
1483 && SUCCEEDED(tempFolder->lpVtbl->QueryInterface(tempFolder,
1484 &kIID_IStorageItem,
1485 &tempFolderItem))
1486 && SUCCEEDED(tempFolderItem->lpVtbl->get_Path(tempFolderItem,
1487 &tempPath))) {
1488 UINT32 tempPathLen;
1489 const wchar_t* tempPathBuf =
1490 WindowsGetStringRawBuffer(tempPath, &tempPathLen);
1490
1491 buf[0] = '\0';
1492 if (wcsncat_s(buf, bufLen, tempPathBuf, tempPathLen) == 0
1493 && wcscat_s(buf, bufLen, L"\\") == 0
1494 && wcscat_s(buf, bufLen, TEXT(GC_LOG_STD_NAME)) == 0)
1495 result = TRUE;
1496 WindowsDeleteString(tempPath);
1497 }
1498
1499 if (tempFolderItem != NULL)
1500 tempFolderItem->lpVtbl->Release(tempFolderItem);
1501 if (tempFolder != NULL)
1502 tempFolder->lpVtbl->Release(tempFolder);
1503 if (appData != NULL)
1504 appData->lpVtbl->Release(appData);
1505 appDataStatics->lpVtbl->Release(appDataStatics);
1506 }
1507 return result;
1508 }
1509 # endif /* MSWINRT_FLAVOR */
我已经使用了ChatGPT,但没有找到任何地方。对于堆栈溢出错误,它给出了下面的代码来替换 misc.c 文件中第 309 行附近的代码。
# if defined(ASM_CLEAR_CODE)
void *GC_clear_stack_inner(void *, ptr_t);
# else
/* Clear the stack up to about limit. Return arg. This function */
/* is now iterative to avoid stack overflow issues. */
void *GC_clear_stack_inner(void *arg,
# if defined(__APPLE_CC__) && !GC_CLANG_PREREQ(6, 0)
volatile /* to workaround some bug */
# endif
ptr_t limit)
{
# define CLEAR_SIZE 213 /* granularity */
while ((word)GC_approx_sp() COOLER_THAN (word)limit) {
volatile word dummy[CLEAR_SIZE];
BZERO((/* no volatile */ void *)dummy, sizeof(dummy));
/* Previously recursive call is now simulated by this loop, */
/* ensuring we don't overflow the stack with deep recursion. */
/* Adjust 'limit' as necessary if the condition needs refining.*/
/* GC_noop1((word)dummy); No longer necessary. */
}
return(arg);
}
# endif /* !ASM_CLEAR_CODE */
在使用此建议之前,我在 Hololens 上看到了圆圈。但在此更改之后,我什至无法从 HoloLens 上的应用程序菜单中打开该应用程序。 我是一个完全的新手,试图学习如何使用 Unity 创建交互并将其部署到 HoloLens 上,但这是一个糟糕的开始。
我遇到了同样的异常,我使用混合现实功能工具安装了 MRTK3 软件包。你找到解决办法了吗?