私は Revmob Unity Plugin を統合し、ほぼ 8 ~ 10 個のフルスクリーン ビデオで問題なく動作しています。その後、静的またはビデオ インタースティシャルをダウンロードせず、「RAM がいっぱいで、何もダウンロードできません」と表示されます。静的とビデオの両方で Release() を呼び出してみましたが、何も機能していないようです。
8 ~ 10 個のビデオを繰り返しキャッシュして再生すると、正常に動作します。その後、完全に停止しています。回復することを期待して1〜2時間近く待ちましたが:(
これは unity revmob プラグインの問題ですか ????
ラファエル、これはいつでも再現できます。3つのデバイスでこれを試しました。1GB RAM の Samsung Mega 5.8 で 8 本のビデオを視聴した後、この問題を再現できます。
4GB RAM を搭載した ASUS zenphone では、20 ~ 30 本のビデオを再生すると RAM 使用量が増加することがわかります。
ところで、私は他の広告ネットワークの統合に疑問を持っていたので、すべての広告ネットワークを削除し、これを単独でテストしてこの問題を再現しました.
いくつか質問があります: RevmobFullScreen クラスで Release() メソッドを使用するのは何ですか。サンプルファイルでそれを使用している人を見つけることができません。clickonad と closead 関数の後に Release() を使用すると、5 ~ 6 個のビデオを再生でき、Release() 呼び出しなしで 8 ~ 10 個のビデオを再生できます。Release() を使用してメモリが解放されることはありません。このメソッドの呼び出しはオプションですか、それとも副作用がありますか?
また、広告を閉じたりクリックした後にビデオを繰り返しキャッシュすると、メモリ リークが発生しますか????? cos、これは私がRevmobで行っている唯一のことであり、他には何もありません
ご参考までに、私のコードを添付します。
using UnityEngine;
using System.Collections;
using System;
using System.Collections.Generic;
public class RevmobController : BaseController, IRevMobListener {
private Dictionary<string, string> REVMOB_APP_IDS;
private static RevMob revmob;
private static RevMobBanner banner;
private static RevMobFullscreen fullscreenStatic;
private static RevMobFullscreen fullscreenVideo;
public bool bannerAdsOnBootup;
public bool interstitialAdsOnBootup;
private bool fullscreenStaticAvailable;
private bool fullscreenVideoAvailable;
public bool createBanner;
private static RevmobController adsController;
public string androidMediaId;
public string iosMediaId;
private enum TYPE_OF_AD {STATIC, VIDEO};
private TYPE_OF_AD typeOfAd;
public static RevmobController SharedInstance() {
return adsController;
}
void Awake() {
adsController = this;
DontDestroyOnLoad( adsController );
REVMOB_APP_IDS = new Dictionary<string, string>() {
{ "Android", androidMediaId},
{ "IOS", iosMediaId }
};
revmob = RevMob.Start (REVMOB_APP_IDS, gameObject.name);
}
// Use this for initialization
void Start () {
}
public bool ShowFullscreenStatic(string location)
{
if( !fullscreenStaticAvailable ) {
return false;
}
this.location = location;
StartCoroutine( LoadInterstitial(location));
return true;
}
IEnumerator LoadInterstitial( string location ) {
yield return null;
fullscreenStatic.Show();
}
public bool ShowFullscreenVideo(string location)
{
if( !fullscreenVideoAvailable ) {
return false;
}
this.location = location;
StartCoroutine( LoadVideoInterstitial(location));
return true;
}
IEnumerator LoadVideoInterstitial( string location ) {
yield return null;
fullscreenVideo.ShowVideo();
}
public void CacheStaticInterstitial(string location) {
if( !AdsService.SharedInstance().IsInternetConnected()) {
return;
}
DestroyStatic();
StartCoroutine(CacheAfterEndofFrame(location, TYPE_OF_AD.STATIC));
}
public void CacheVideoInterstitial() {
if( !AdsService.SharedInstance().IsInternetConnected()) {
return;
}
DestroyVideo();
StartCoroutine(CacheAfterEndofFrame(location, TYPE_OF_AD.VIDEO));
}
IEnumerator CacheAfterEndofFrame(string location, TYPE_OF_AD typeOfAd) {
yield return null;
this.typeOfAd = typeOfAd;
if( typeOfAd == TYPE_OF_AD.STATIC ) {
fullscreenStatic = revmob.CreateFullscreen(location);
} else {
fullscreenVideo = revmob.CreateVideo(location);
}
}
public void SessionIsStarted ()
{
Debug.Log("Session started.");
if( createBanner ) {
banner= revmob.CreateBanner();
}
CacheStaticInterstitial("Bootup");
CacheVideoInterstitial();
if( bannerAdsOnBootup && banner != null ) {
if (PlayerPrefs.GetInt("removeads",0) == 0) {
banner.Show();
}
}
}
public void SessionNotStarted (string revMobAdType)
{
Debug.Log("Session not started.");
}
public void AdDidReceive (string revMobAdType)
{
Debug.Log("Ad did receive.");
if( typeOfAd == TYPE_OF_AD.STATIC ) {
fullscreenStaticAvailable = true;
} else if( typeOfAd == TYPE_OF_AD.VIDEO ) {
fullscreenVideoAvailable = true;
}
if( interstitialAdsOnBootup ) {
ShowFullscreenStatic("Bootup");
interstitialAdsOnBootup = false;
fullscreenStaticAvailable = false;
}
}
public void AdDidFail (string revMobAdType)
{
Debug.Log("Ad did fail.");
}
public void AdDisplayed (string revMobAdType)
{
Debug.Log("Ad displayed.");
AdsService.SharedInstance().PauseAudio();
}
public void UserClickedInTheAd (string revMobAdType)
{
Debug.Log("Ad clicked.");
if( typeOfAd == TYPE_OF_AD.STATIC ) {
fullscreenStaticAvailable = false;
DestroyStatic();
//CacheStaticInterstitial();
} else if( typeOfAd == TYPE_OF_AD.VIDEO ) {
fullscreenVideoAvailable = false;
DestroyVideo();
//CacheVideoInterstitial();
}
}
public void UserClosedTheAd (string revMobAdType)
{
Debug.Log("Ad closed.");
AdsService.SharedInstance().ResumeAudio();
CallOnAdComplete(this.location);
if( typeOfAd == TYPE_OF_AD.STATIC ) {
fullscreenStaticAvailable = false;
DestroyStatic();
//CacheStaticInterstitial();
} else if( typeOfAd == TYPE_OF_AD.VIDEO ) {
fullscreenVideoAvailable = false;
DestroyVideo();
//CacheVideoInterstitial();
}
}
void DestroyStatic() {
if( fullscreenStatic != null ) {
//fullscreenStatic.Hide();
//fullscreenStatic.Release();
//fullscreenStatic = null;
}
}
void DestroyVideo() {
if( fullscreenVideo != null ) {
//fullscreenVideo.Hide();
//fullscreenVideo.Release();
//fullscreenVideo = null;
}
}
public void VideoStarted() {
}
public void VideoFinished() {
//fullscreenVideoAvailable = false;
/*fullscreenVideo.Release();
fullscreenVideo = revmob.CreateVideo();*/
}
public void VideoLoaded() {
fullscreenVideoAvailable = true;
}
public void VideoNotCompletelyLoaded() {
}
public void RewardedVideoLoaded() {
}
public void RewardedVideoNotCompletelyLoaded() {
}
public void RewardedVideoStarted() {
}
public void RewardedVideoFinished() {
}
public void RewardedVideoCompleted() {
}
public void RewardedPreRollDisplayed() {
}
void OnDestroy() {
if( banner != null ) {
//banner.Release();
}
if( fullscreenVideo != null ) {
//fullscreenVideo.Release();
}
if( fullscreenStatic != null ) {
//fullscreenStatic.Release();
}
adsController = null;
}
}