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

ios真机运行 #28

Open
yanglijundl opened this issue Aug 25, 2018 · 10 comments
Open

ios真机运行 #28

yanglijundl opened this issue Aug 25, 2018 · 10 comments

Comments

@yanglijundl
Copy link

我今天更新了一下你的新提交 发现在ios真机运行 Ensure all async operations are complete before unloading bundles.

@yanglijundl
Copy link
Author

assetbundle.Unload(unloadAllLoadedObjects); 这个地方 会出现依赖被卸载的情况 unity2018.2 ios下

@smilehao
Copy link
Owner

看起来是AB还在异步加载,就调用了卸载操作,你什么时候手动调用的卸载?

@smilehao
Copy link
Owner

-- 等待资源管理器加载任务结束,否则很多Unity版本在切场景时会有异常,甚至在真机上crash
coroutine.waitwhile(function()
    return ResourcesManager:GetInstance():IsProsessRunning()
end)

用这个可以判断

@yanglijundl
Copy link
Author

void OnProsessingAssetBundleAsyncLoader()
{
for (int i = prosessingAssetBundleAsyncLoader.Count - 1; i >= 0; i--)
{
var loader = prosessingAssetBundleAsyncLoader[i];
loader.Update();
if (loader.IsDone())
{
UnloadAssetBundle(loader.assetbundleName);
prosessingAssetBundleAsyncLoader.RemoveAt(i);
}
}
}
发现问题了 是这个地方的unloadAssetBundle 引起的 这行注释了 不知道 会有什么影响

@smilehao
Copy link
Owner

你拉下最新代码试试,这个代码已经是旧的了,然后刚刚又修复了一个问题:

    void OnProsessingAssetBundleAsyncLoader()
    {
        for (int i = prosessingAssetBundleAsyncLoader.Count - 1; i >= 0; i--)
        {
            var loader = prosessingAssetBundleAsyncLoader[i];
            loader.Update();
            if (loader.IsDone())
            {
                // 解除加载器对AB持有的引用
                int count = DecreaseReferenceCount(loader.assetbundleName);
                if (count <= 0)
                {
                    UnloadAssetBundle(loader.assetbundleName);
                }
                prosessingAssetBundleAsyncLoader.RemoveAt(i);
            }
        }
    }

@yanglijundl
Copy link
Author

嗯 我修改了 真机尝试 资源还是会被卸载,我把UnloadAssetBundle(loader.assetbundleName);注释掉就没有用问题。不知道这一句注释掉之后 会有什么影响

@yanglijundl
Copy link
Author

问题解决了
void OnProsessingAssetBundleAsyncLoader()
{
for (int i = prosessingAssetBundleAsyncLoader.Count - 1; i >= 0; i--)
{
var loader = prosessingAssetBundleAsyncLoader[i];
loader.Update();
if (loader.IsDone())
{
// 解除加载器对AB持有的引用
int count = DecreaseReferenceCount(loader.assetbundleName);
if (count <= 0)
{
//UnloadAssetBundle(loader.assetbundleName);
StartCoroutine(unloadCrotine(loader.assetbundleName));
}
prosessingAssetBundleAsyncLoader.RemoveAt(i);
}
}
}

    IEnumerator unloadCrotine(string assetbundleName)
    {
        yield return new WaitForSeconds(0.1f);
        UnloadAssetBundle(assetbundleName);
    }

@smilehao
Copy link
Owner

这种方式没有解决根本问题,我再找找原因,这里本意是去除创建器引用

@yanglijundl
Copy link
Author

嗯 好的

@wanwanyahoo
Copy link

请问下,这个问题有后续吗?
2017.4.19上,也有同样的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants