Some Cerberus improvements

AntonM

New member
Joined
Aug 16, 2017
Messages
7
After the release of the game on mobile platforms, I have several changes in Сerberus, maybe it will be useful for someone.

iOS
Cerberus on iOS currently caches loaded images, which uses a lot of memory and when images are deleted in the game, the memory is not immediately released. Cached images should be deleted if there is not much memory left in the application and the app receives memory warning messages, but my game simply crashed on older devices due to lack of memory. To load images without caching, replace image = [UIImage imageNamed: path.ToNSString ()]; in iosgame.cpp LoadImageData by this

Objective-C:
        NSString *thePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: path.ToNSString()];
        image = [[UIImage alloc] initWithContentsOfFile:thePath];

I was also unable to fix this error. I do not know if anyone else has similar errors, but it produces a lot of crashes for me. This error occurs on ios 12 and later, and I can't even reproduce it. If only someone could fix it it would be good.

Android
To make the game work without a navigation bar on phones with wide screens.
In androidgame.java added UpdateUI() in onWindowFocusChanged()
Java:
    public void UpdateUI(){
        _view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
                |View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
                | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
    }

Also I had this error https://stackoverflow.com/questions/31439228/exception-in-the-androids-code-while-starting-the-app/
Fixed added this in Activity OnCreate()
Java:
        if (getResources() == null) {
            bb_std_lang.error("");
        }

Another bug was in mojo.android.java gxtkAudio StopMusic(), the game crashed in this place for some reason. I can't find a link to it right now, but the solution was to remove music.stop();

I also commented out the accelerometer code in BBAndroidGame.onSensorChanged(), because the accelerometer was not used in the game and generated a lot of ARN errors. In general, the android target works well, in Google Play the Crash Rate is about 0.03% and ARN 0.06%, which I think is very good.
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,167
I was also unable to fix this error. I do not know if anyone else has similar errors, but it produces a lot of crashes for me. This error occurs on ios 12 and later, and I can't even reproduce it. If only someone could fix it it would be good.
As no one seems to have experienced this problem besides you and you changed the image caching, I get the feeling that your change isn't compatible with the garbage collector. The error your describe means, that ios12 tried to access memory, that is freed already.
Without a small sample project which shows the problem and that we can use to test this, there is not much to luck into.
 

AntonM

New member
Joined
Aug 16, 2017
Messages
7
I do not know if anyone has released applications in the app store here to see what errors there are. Because it is better to check on a large number of devices.
 

Martin

Active member
CX Code Contributor
3rd Party Module Dev
Tutorial Author
Joined
Jun 19, 2017
Messages
334
Oh I would have to look into that. But I have to admit my apps were from 2012-2016 or so, so that's been a while. I haven't checked against later iOS versions actually.
 
Top Bottom