forked from organicmaps/organicmaps
Merge pull request #5148 from mapsme/ios-destroy-context-on-bg
[ios] Added destroying GL context on entering background
This commit is contained in:
commit
47ffe51955
7 changed files with 132 additions and 74 deletions
|
@ -1,5 +1,4 @@
|
|||
#import "MWMRateAlert.h"
|
||||
#import <sys/utsname.h>
|
||||
#import "AppInfo.h"
|
||||
#import "MWMAlertViewController.h"
|
||||
#import "MWMMailViewController.h"
|
||||
|
@ -11,7 +10,6 @@
|
|||
#include "platform/platform.hpp"
|
||||
|
||||
extern NSString * const kUDAlreadyRatedKey;
|
||||
extern NSDictionary * const kDeviceNames;
|
||||
extern NSString * const kLocaleUsedInSupportEmails;
|
||||
extern NSString * const kRateAlertEventName = @"rateAlertEvent";
|
||||
static NSString * const kRateAlertNibName = @"MWMRateAlert";
|
||||
|
@ -142,12 +140,7 @@ static NSString * const kStatisticsEvent = @"Rate Alert";
|
|||
alertController.view.alpha = 0.;
|
||||
if ([MWMMailViewController canSendMail])
|
||||
{
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
NSString * machine = @(systemInfo.machine);
|
||||
NSString * device = kDeviceNames[machine];
|
||||
if (!device)
|
||||
device = machine;
|
||||
NSString * device = [AppInfo sharedInfo].deviceName;
|
||||
NSString * languageCode = [[NSLocale preferredLanguages] firstObject];
|
||||
NSString * language = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails]
|
||||
displayNameForKey:NSLocaleLanguageCode
|
||||
|
|
|
@ -627,7 +627,17 @@ using namespace osm_auth_ios;
|
|||
LOG(LINFO, ("applicationWillResignActive"));
|
||||
[self.mapViewController onGetFocus:NO];
|
||||
[MWMRouterSavedState store];
|
||||
GetFramework().SetRenderingDisabled(false);
|
||||
// On some devices we have to free all belong-to-graphics memory
|
||||
// because of new OpenGL driver powered by Metal.
|
||||
if ([AppInfo sharedInfo].isMetalDriver)
|
||||
{
|
||||
GetFramework().SetRenderingDisabled(true);
|
||||
GetFramework().OnDestroyGLContext();
|
||||
}
|
||||
else
|
||||
{
|
||||
GetFramework().SetRenderingDisabled(false);
|
||||
}
|
||||
[MWMLocationManager applicationWillResignActive];
|
||||
}
|
||||
|
||||
|
@ -663,6 +673,13 @@ using namespace osm_auth_ios;
|
|||
[self handleURLs];
|
||||
[[Statistics instance] applicationDidBecomeActive];
|
||||
GetFramework().SetRenderingEnabled();
|
||||
// On some devices we have to free all belong-to-graphics memory
|
||||
// because of new OpenGL driver powered by Metal.
|
||||
if ([AppInfo sharedInfo].isMetalDriver)
|
||||
{
|
||||
m2::PointU size = GetFramework().GetViewportPixelSize();
|
||||
GetFramework().OnRecoverGLContext(static_cast<int>(size.x), static_cast<int>(size.y));
|
||||
}
|
||||
[MWMLocationManager applicationDidBecomeActive];
|
||||
[MWMRouterSavedState restore];
|
||||
[MWMSearch addCategoriesToSpotlight];
|
||||
|
|
|
@ -12,5 +12,7 @@
|
|||
@property(nonatomic, readonly) NSUUID * advertisingId;
|
||||
@property(nonatomic, readonly) NSString * languageId;
|
||||
@property(nonatomic, readonly) NSDate * buildDate;
|
||||
@property(nonatomic, readonly) NSString * deviceName;
|
||||
@property(nonatomic, readonly) BOOL isMetalDriver;
|
||||
|
||||
@end
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#import <CoreTelephony/CTCarrier.h>
|
||||
#import <CoreTelephony/CTTelephonyNetworkInfo.h>
|
||||
#import <sys/utsname.h>
|
||||
#import "MWMCommon.h"
|
||||
|
||||
#include "platform/settings.hpp"
|
||||
|
||||
|
@ -10,6 +11,77 @@ extern string const kCountryCodeKey = "CountryCode";
|
|||
extern string const kUniqueIdKey = "UniqueId";
|
||||
extern string const kLanguageKey = "Language";
|
||||
|
||||
namespace
|
||||
{
|
||||
NSDictionary * const kDeviceNamesBeforeMetalDriver = @{
|
||||
@"i386" : @"Simulator",
|
||||
@"iPad1,1" : @"iPad WiFi",
|
||||
@"iPad1,2" : @"iPad GSM",
|
||||
@"iPad2,1" : @"iPad 2 WiFi",
|
||||
@"iPad2,2" : @"iPad 2 CDMA",
|
||||
@"iPad2,2" : @"iPad 2 GSM",
|
||||
@"iPad2,3" : @"iPad 2 GSM EV-DO",
|
||||
@"iPad2,4" : @"iPad 2",
|
||||
@"iPad2,5" : @"iPad Mini WiFi",
|
||||
@"iPad2,6" : @"iPad Mini GSM",
|
||||
@"iPad2,7" : @"iPad Mini CDMA",
|
||||
@"iPad3,1" : @"iPad 3rd gen. WiFi",
|
||||
@"iPad3,2" : @"iPad 3rd gen. GSM",
|
||||
@"iPad3,3" : @"iPad 3rd gen. CDMA",
|
||||
@"iPad3,4" : @"iPad 4th gen. WiFi",
|
||||
@"iPad3,5" : @"iPad 4th gen. GSM",
|
||||
@"iPad3,6" : @"iPad 4th gen. CDMA",
|
||||
@"iPad4,1" : @"iPad Air WiFi",
|
||||
@"iPad4,2" : @"iPad Air GSM",
|
||||
@"iPad4,3" : @"iPad Air CDMA",
|
||||
@"iPad4,4" : @"iPad Mini 2nd gen. WiFi",
|
||||
@"iPad4,5" : @"iPad Mini 2nd gen. GSM",
|
||||
@"iPad4,6" : @"iPad Mini 2nd gen. CDMA",
|
||||
@"iPad5,3" : @"iPad Air 2 WiFi",
|
||||
@"iPad5,4" : @"iPad Air 2 GSM",
|
||||
@"iPhone1,1" : @"iPhone",
|
||||
@"iPhone1,2" : @"iPhone 3G",
|
||||
@"iPhone2,1" : @"iPhone 3GS",
|
||||
@"iPhone3,1" : @"iPhone 4 GSM",
|
||||
@"iPhone3,2" : @"iPhone 4 CDMA",
|
||||
@"iPhone3,3" : @"iPhone 4 GSM EV-DO",
|
||||
@"iPhone4,1" : @"iPhone 4S",
|
||||
@"iPhone4,2" : @"iPhone 4S",
|
||||
@"iPhone4,3" : @"iPhone 4S",
|
||||
@"iPhone5,1" : @"iPhone 5",
|
||||
@"iPhone5,2" : @"iPhone 5",
|
||||
@"iPhone5,3" : @"iPhone 5c",
|
||||
@"iPhone5,4" : @"iPhone 5c",
|
||||
@"iPhone6,1" : @"iPhone 5s",
|
||||
@"iPhone6,2" : @"iPhone 5s",
|
||||
@"iPhone7,1" : @"iPhone 6 Plus",
|
||||
@"iPhone7,2" : @"iPhone 6",
|
||||
@"iPod1,1" : @"iPod Touch",
|
||||
@"iPod2,1" : @"iPod Touch 2nd gen.",
|
||||
@"iPod3,1" : @"iPod Touch 3rd gen.",
|
||||
@"iPod4,1" : @"iPod Touch 4th gen.",
|
||||
@"iPod5,1" : @"iPod Touch 5th gen.",
|
||||
@"x86_64" : @"Simulator"
|
||||
};
|
||||
|
||||
NSDictionary * const kDeviceNamesWithiOS10MetalDriver = @{
|
||||
@"iPad6,3" : @"iPad Pro (9.7 inch) WiFi",
|
||||
@"iPad6,4" : @"iPad Pro (9.7 inch) GSM",
|
||||
@"iPad6,7" : @"iPad Pro (12.9 inch) WiFi",
|
||||
@"iPad6,8" : @"iPad Pro (12.9 inch) GSM",
|
||||
@"iPhone8,1" : @"iPhone 6s",
|
||||
@"iPhone8,2" : @"iPhone 6s Plus",
|
||||
@"iPhone8,4" : @"iPhone SE"
|
||||
};
|
||||
NSDictionary * const kDeviceNamesWithMetalDriver = @{
|
||||
@"iPhone9,1" : @"iPhone 7",
|
||||
@"iPhone9,2" : @"iPhone 7 Plus",
|
||||
@"iPhone9,3" : @"iPhone 7",
|
||||
@"iPhone9,4" : @"iPhone 7 Plus"
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
@interface AppInfo ()
|
||||
|
||||
@property(nonatomic) NSString * countryCode;
|
||||
|
@ -19,6 +91,7 @@ extern string const kLanguageKey = "Language";
|
|||
@property(nonatomic) NSString * deviceInfo;
|
||||
@property(nonatomic) NSUUID * advertisingId;
|
||||
@property(nonatomic) NSDate * buildDate;
|
||||
@property(nonatomic) NSString * deviceName;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -141,4 +214,34 @@ extern string const kLanguageKey = "Language";
|
|||
return _buildDate;
|
||||
}
|
||||
|
||||
- (NSString *)deviceName
|
||||
{
|
||||
if (!_deviceName)
|
||||
{
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
NSString * machine = @(systemInfo.machine);
|
||||
_deviceName = kDeviceNamesBeforeMetalDriver[machine];
|
||||
if (!_deviceName)
|
||||
_deviceName = kDeviceNamesWithiOS10MetalDriver[machine];
|
||||
if (!_deviceName)
|
||||
_deviceName = kDeviceNamesWithMetalDriver[machine];
|
||||
else
|
||||
_deviceName = machine;
|
||||
}
|
||||
return _deviceName;
|
||||
}
|
||||
|
||||
- (BOOL)isMetalDriver
|
||||
{
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
NSString * machine = @(systemInfo.machine);
|
||||
if (kDeviceNamesBeforeMetalDriver[machine] != nil)
|
||||
return NO;
|
||||
if (kDeviceNamesWithiOS10MetalDriver[machine] != nil)
|
||||
return !isIOSVersionLessThan(10);
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#import "MWMHelpController.h"
|
||||
#import <sys/utsname.h>
|
||||
#import "AppInfo.h"
|
||||
#import "MWMCommon.h"
|
||||
#import "MWMMailViewController.h"
|
||||
|
@ -13,63 +12,6 @@
|
|||
|
||||
extern NSString * const kAlohalyticsTapEventKey;
|
||||
extern NSString * const kLocaleUsedInSupportEmails = @"en_gb";
|
||||
extern NSDictionary * const kDeviceNames = @{
|
||||
@"i386" : @"Simulator",
|
||||
@"iPad1,1" : @"iPad WiFi",
|
||||
@"iPad1,2" : @"iPad GSM",
|
||||
@"iPad2,1" : @"iPad 2 WiFi",
|
||||
@"iPad2,2" : @"iPad 2 CDMA",
|
||||
@"iPad2,2" : @"iPad 2 GSM",
|
||||
@"iPad2,3" : @"iPad 2 GSM EV-DO",
|
||||
@"iPad2,4" : @"iPad 2",
|
||||
@"iPad2,5" : @"iPad Mini WiFi",
|
||||
@"iPad2,6" : @"iPad Mini GSM",
|
||||
@"iPad2,7" : @"iPad Mini CDMA",
|
||||
@"iPad3,1" : @"iPad 3rd gen. WiFi",
|
||||
@"iPad3,2" : @"iPad 3rd gen. GSM",
|
||||
@"iPad3,3" : @"iPad 3rd gen. CDMA",
|
||||
@"iPad3,4" : @"iPad 4th gen. WiFi",
|
||||
@"iPad3,5" : @"iPad 4th gen. GSM",
|
||||
@"iPad3,6" : @"iPad 4th gen. CDMA",
|
||||
@"iPad4,1" : @"iPad Air WiFi",
|
||||
@"iPad4,2" : @"iPad Air GSM",
|
||||
@"iPad4,3" : @"iPad Air CDMA",
|
||||
@"iPad4,4" : @"iPad Mini 2nd gen. WiFi",
|
||||
@"iPad4,5" : @"iPad Mini 2nd gen. GSM",
|
||||
@"iPad4,6" : @"iPad Mini 2nd gen. CDMA",
|
||||
@"iPad5,3" : @"iPad Air 2 WiFi",
|
||||
@"iPad5,4" : @"iPad Air 2 GSM",
|
||||
@"iPad6,3" : @"iPad Pro (9.7 inch) WiFi",
|
||||
@"iPad6,4" : @"iPad Pro (9.7 inch) GSM",
|
||||
@"iPad6,7" : @"iPad Pro (12.9 inch) WiFi",
|
||||
@"iPad6,8" : @"iPad Pro (12.9 inch) GSM",
|
||||
@"iPhone1,1" : @"iPhone",
|
||||
@"iPhone1,2" : @"iPhone 3G",
|
||||
@"iPhone2,1" : @"iPhone 3GS",
|
||||
@"iPhone3,1" : @"iPhone 4 GSM",
|
||||
@"iPhone3,2" : @"iPhone 4 CDMA",
|
||||
@"iPhone3,3" : @"iPhone 4 GSM EV-DO",
|
||||
@"iPhone4,1" : @"iPhone 4S",
|
||||
@"iPhone4,2" : @"iPhone 4S",
|
||||
@"iPhone4,3" : @"iPhone 4S",
|
||||
@"iPhone5,1" : @"iPhone 5",
|
||||
@"iPhone5,2" : @"iPhone 5",
|
||||
@"iPhone5,3" : @"iPhone 5c",
|
||||
@"iPhone5,4" : @"iPhone 5c",
|
||||
@"iPhone6,1" : @"iPhone 5s",
|
||||
@"iPhone6,2" : @"iPhone 5s",
|
||||
@"iPhone7,1" : @"iPhone 6 Plus",
|
||||
@"iPhone7,2" : @"iPhone 6",
|
||||
@"iPhone8,1" : @"iPhone 6s",
|
||||
@"iPhone8,2" : @"iPhone 6s Plus",
|
||||
@"iPhone8,4" : @"iPhone SE",
|
||||
@"iPod1,1" : @"iPod Touch",
|
||||
@"iPod2,1" : @"iPod Touch 2nd gen.",
|
||||
@"iPod3,1" : @"iPod Touch 3rd gen.",
|
||||
@"iPod4,1" : @"iPod Touch 4th gen.",
|
||||
@"iPod5,1" : @"iPod Touch 5th gen.",
|
||||
@"x86_64" : @"Simulator",
|
||||
};
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -201,13 +143,7 @@ NSString * const kiOSEmail = @"ios@maps.me";
|
|||
{
|
||||
if ([MWMMailViewController canSendMail])
|
||||
{
|
||||
struct utsname systemInfo;
|
||||
uname(&systemInfo);
|
||||
NSString * machine =
|
||||
[NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];
|
||||
NSString * device = kDeviceNames[machine];
|
||||
if (!device)
|
||||
device = machine;
|
||||
NSString * device = [AppInfo sharedInfo].deviceName;
|
||||
NSString * languageCode = [[NSLocale preferredLanguages] firstObject];
|
||||
NSString * language = [[NSLocale localeWithLocaleIdentifier:kLocaleUsedInSupportEmails]
|
||||
displayNameForKey:NSLocaleLanguageCode
|
||||
|
|
|
@ -1051,6 +1051,12 @@ m2::PointD Framework::GetPixelCenter() const
|
|||
: m_currentModelView.PixelRect().Center();
|
||||
}
|
||||
|
||||
m2::PointU Framework::GetViewportPixelSize() const
|
||||
{
|
||||
auto & rect = m_currentModelView.PixelRect();
|
||||
return m2::PointU(static_cast<uint32_t>(rect.SizeX()), static_cast<uint32_t>(rect.SizeY()));
|
||||
}
|
||||
|
||||
m2::PointD Framework::GetVisiblePixelCenter() const
|
||||
{
|
||||
return m_visibleViewport.Center();
|
||||
|
|
|
@ -563,6 +563,7 @@ public:
|
|||
|
||||
m2::PointD GetPixelCenter() const;
|
||||
m2::PointD GetVisiblePixelCenter() const;
|
||||
m2::PointU GetViewportPixelSize() const;
|
||||
|
||||
m2::PointD const & GetViewportCenter() const;
|
||||
void SetViewportCenter(m2::PointD const & pt);
|
||||
|
|
Loading…
Add table
Reference in a new issue