- 如何解决小程序不断进行错峰播放svga跟mp4的时候「小程序运行内存不足」的问题?
使用uniapp开发微信小程序,有个页面会不断的错峰播放svga跟mp4(直播送礼物),当播放数量达到一定时会出现「小程序运行内存不足」,然后把小程序闪退,有时会直接把微信整个闪退掉,如何在播放后及时清除缓存与释放资源?播放的时候使用v-if轮流显示隐藏。 此外,在App.vue中加入了手动进行垃圾回收机制 onShow(() => { console.log("App Show"); uni.onMemoryWarning(go2triggerGC); }); onHide(() => { console.log("App Hide"); uni.offMemoryWarning(go2triggerGC); }); const go2triggerGC = () => { // #ifdef MP-WEIXIN // 手动进行垃圾回收 if (wx.triggerGC) { wx.triggerGC() } // #endif // uni.showToast({ // title: "警告!!内存不足!!!", // icon: "none", // duration: 4000, // }); }
2024-02-06 - 如何解决小程序错峰播放svga跟mp4礼物特效的时候出现的「小程序运行内存不足」的问题?
uniapp框架下: 在全局定义了一个礼物队列数组:giftUrls(送出礼物就往里面push一个礼物的url) 在页面创建一个空的播放队列数组:playGiftUrls 监听playGiftUrls数组,当它长度等于0的时候才会从giftUrls转移一个url到playGiftUrls,保证playGiftUrls有且仅有一个礼物在播放 <template v-for="(item, i) in playGiftUrls" :key="i"> <view class="yyeva f-pf f-vw100 f-vh100"> <yyeva v-if="item.src" :options="item.src" @onEnd="() => onFinished()" /> <c-svga v-else width="100%" height="100%" :src="item.url" :loops="1" @finished="() => onFinished()" /> </view> </template> 然后在finished方法里每次移除playGiftUrls内的url function onFinished() { playGiftUrls.value.shift(); } 当播放的礼物特别多的时候,会出现「小程序运行内存不足」,从而导致小程序闪退或者直接微信闪退。请问如何及时清理礼物的缓存避免这种问题? 已经在App.vue里添加了下面的代码: onShow(() => { console.log("App Show"); uni.onMemoryWarning(go2triggerGC); }); onHide(() => { console.log("App Hide"); uni.offMemoryWarning(go2triggerGC); }); const go2triggerGC = () => { // #ifdef MP-WEIXIN // 手动进行垃圾回收 if (wx.triggerGC) { wx.triggerGC() } // #endif uni.showToast({ title: "警告!!内存不足!!!", icon: "none", duration: 4000, }); }
2024-01-26 - 从非 tabbar 页面跳转到 tabbar 页面时候如何不关闭当前页面进行跳转?
【前置条件】语聊房是个二级页面(非 tabbar页面) 【需求分析】从语聊房离开页面时,保持 TRTC 通话在后台继续正常进行通话,直到进入其他语聊房或通过手动按钮关闭通话 【问题描述】从语聊房跳转至首页(tabbar页面)时,由于小程序跳转 API 限制,switchTab 与 navigateBack 均会关闭语聊房页面,从而导致 TRTC 断开。”
2024-01-22 - 新增「社交-笔记」类目审核已经7天了,是否能加急处理?后天就要举办活动了,就等新版本发布了
[图片]
2023-11-08 - 原生tabbar安卓机型来回切换的时候会闪一下,这是为什么?(IOS机型正常)
"tabBar": { "color": "#666666", "selectedColor": "#EDB93F", "backgroundColor": "#303030", "list": [{ "pagePath": "pages/forum/forum", "text": "页面一", "iconPath": "/images/tabbarIcon/forum.png", "selectedIconPath": "/images/tabbarIcon/forum-active.png" }, { "pagePath": "pages/stone/stone", "text": "页面二", "iconPath": "/images/tabbarIcon/stone.png", "selectedIconPath": "/images/tabbarIcon/stone-active.png" }, { "pagePath": "pages/timeBadge/timeBadge", "text": "页面三", "iconPath": "/images/tabbarIcon/badge.png", "selectedIconPath": "/images/tabbarIcon/badge-active.png" } ] } 直接设置的原生的tabbar
2020-06-03