Pasted the email conversation below:
Hi Johnny,
If I remember correctly, 112-115 was done to handle a timing issue that the sponsor framework is being downloaded -> extracted -> dynamically linked asynchronously and in the background with respect to the UI.
So, there maybe a situation where the user is already on the sponsor screen and waiting for the sponsor framework to load and show the sponsor UI.
However, while the user is waiting, if the loading fails or if sponsor framework cannot be downloaded, then the user is waiting forever since there is no trigger to go to the next step.
I agree to the fact that we are trying to do too many things in this method and we can definitely refactor and simplify it. But that is for 9.0.1 since no refactoring/design changes are going into JDK9 at this point.
Thanks,
- Pranav
On Jun 28, 2016, at 7:10 PM, Johnny Chen <jia-hong.chen@oracle.com> wrote:
Hi Pranav,
While researching JDK-8058593 and staring at ThirdParty.m, I found that we should be able to safely remove lines [112, 115].
Reason is that if self.viewController is nil, something in the Sponsors.framework is wrong and we won’t be able to offer the sponsor screen,
which can be handled in the fallthrough of the if(self.viewController)-block at lines 129-130.
If you agree, I will create a JDK bug to check in this cleanup for jdk9 client.
74 // This method serves a double purpose where the main purpose is to dynamically link the downloaded
75 // sponsor framework and to subsequently invoke/offer the sponsor screen. The second purpose,
76 // due to the asynchronous nature of SPDownloader, is for the client to indicate the failure of the
77 // downloading process and to allow the installation to go on without the sponsor screen.
78 //
79 // The client indicates the failure of the downloading process by passing dyPath == nil.
80 - (void) linkDynamicLib:(NSString *)dyPath
81 {
82 self.viewController = nil;
83
84 if (dyPath == nil) {
85 // Offer disabled due to inet connectivity issue
86 [self.mainViewControllerRef.installState setSponsorDisabled];
87 self.mainViewControllerRef.installState.sponsorPing = @"XSP300|-148";
88 [self skipSponsorScreen];
89 return;
90 }
91
92 //[JRELogger Log:Install :Debug :[NSString stringWithFormat:@"Path received:%@", dyPath]];
93 NSString *sponsorPreference = InstallState.stagedXML.sponsorPreference;
94 // Get current country
95 NSString *currentCountry = [self.mainViewControllerRef.engine getCountryCode];
96
97 // Create options to be sent to the Sponsors.framework
98 NSDictionary *spOptions = [NSDictionary dictionaryWithObjectsAndKeys:sponsorPreference,@"SP_PREF",currentCountry,@"COUNTRY_CODE", nil];
99
100 handle = dlopen([[NSString stringWithFormat:@"%@/Sponsors.framework/Sponsors",[dyPath stringByDeletingLastPathComponent]] UTF8String],RTLD_LOCAL);
101
102 self.sponsor = [self executeMethod:@"SponsorFactory" methodName:@"makeSponsor:" methodArgs:(__bridge void *)(spOptions) fp:class_getClassMethod];
103
104 if([sponsor respondsToSelector:NSSelectorFromString(@"getSponsorOffer:")]) {
105 self.viewController = [sponsor performSelector:NSSelectorFromString(@"getSponsorOffer:") withObject:self.mainViewControllerRef];
106
107 // Get SP ID code nevertheless
108 if([sponsor respondsToSelector:NSSelectorFromString(@"getSponsorID")]) {
109 mainViewControllerRef.installState.sponsorID = [sponsor performSelector:NSSelectorFromString(@"getSponsorID")];
110 }
111
112 if(!self.viewController && [[self.mainViewControllerRef.installState getMode] isEqualToString:@"AU"]) {
113 [self.mainViewControllerRef transitionInstallStep:YES];
114 return;
115 }
116 }
117
118 [JRELogger logWithType:Install severity:Debug message:[NSString stringWithFormat:@"Current Step:%d",[self.mainViewControllerRef getCurrentStep]]];
119
120 // If the user is waiting on the sponsor screen for the offer
121 if(self.viewController) {
122 if([self.mainViewControllerRef getCurrentStep] == 1 || [[self.mainViewControllerRef.installState getMode] isEqualToString:@"AU"]) {
123 [self.mainViewControllerRef.mainView.view1 addSubview:[self.viewController view]];
124 [self.mainViewControllerRef lockContinueButton:NO];
125 [self.mainViewControllerRef.mainView.cancelButton setEnabled:YES];
126 [self.indicator removeFromSuperview];
127 }
128 } else {
129 // if sponsor is not to be offered but the user has already reached the sponsor screen
130 [self skipSponsorScreen];
131 }
132 }
133
134 - (void) skipSponsorScreen
135 {
136 // For offline installer, if we already reached the sponsor screen, do a transition.
137 // For AU, since there is no "Welcome Step", do the transition automatically.
138 if([self.mainViewControllerRef getCurrentStep] == 1 ||
139 [[self.mainViewControllerRef.installState getMode] isEqualToString:@"AU"]) {
140 [self.mainViewControllerRef lockContinueButton:NO];
141 [self.mainViewControllerRef.mainView.cancelButton setEnabled:YES];
142 [self.indicator removeFromSuperview];
143 [self.mainViewControllerRef transitionInstallStep:YES];
144 } else {
145 [self.mainViewControllerRef.installSteps removeObjectAtIndex:1];
146 }
147 }
Thanks,
Johnny Chen
Hi Johnny,
If I remember correctly, 112-115 was done to handle a timing issue that the sponsor framework is being downloaded -> extracted -> dynamically linked asynchronously and in the background with respect to the UI.
So, there maybe a situation where the user is already on the sponsor screen and waiting for the sponsor framework to load and show the sponsor UI.
However, while the user is waiting, if the loading fails or if sponsor framework cannot be downloaded, then the user is waiting forever since there is no trigger to go to the next step.
I agree to the fact that we are trying to do too many things in this method and we can definitely refactor and simplify it. But that is for 9.0.1 since no refactoring/design changes are going into JDK9 at this point.
Thanks,
- Pranav
On Jun 28, 2016, at 7:10 PM, Johnny Chen <jia-hong.chen@oracle.com> wrote:
Hi Pranav,
While researching JDK-8058593 and staring at ThirdParty.m, I found that we should be able to safely remove lines [112, 115].
Reason is that if self.viewController is nil, something in the Sponsors.framework is wrong and we won’t be able to offer the sponsor screen,
which can be handled in the fallthrough of the if(self.viewController)-block at lines 129-130.
If you agree, I will create a JDK bug to check in this cleanup for jdk9 client.
74 // This method serves a double purpose where the main purpose is to dynamically link the downloaded
75 // sponsor framework and to subsequently invoke/offer the sponsor screen. The second purpose,
76 // due to the asynchronous nature of SPDownloader, is for the client to indicate the failure of the
77 // downloading process and to allow the installation to go on without the sponsor screen.
78 //
79 // The client indicates the failure of the downloading process by passing dyPath == nil.
80 - (void) linkDynamicLib:(NSString *)dyPath
81 {
82 self.viewController = nil;
83
84 if (dyPath == nil) {
85 // Offer disabled due to inet connectivity issue
86 [self.mainViewControllerRef.installState setSponsorDisabled];
87 self.mainViewControllerRef.installState.sponsorPing = @"XSP300|-148";
88 [self skipSponsorScreen];
89 return;
90 }
91
92 //[JRELogger Log:Install :Debug :[NSString stringWithFormat:@"Path received:%@", dyPath]];
93 NSString *sponsorPreference = InstallState.stagedXML.sponsorPreference;
94 // Get current country
95 NSString *currentCountry = [self.mainViewControllerRef.engine getCountryCode];
96
97 // Create options to be sent to the Sponsors.framework
98 NSDictionary *spOptions = [NSDictionary dictionaryWithObjectsAndKeys:sponsorPreference,@"SP_PREF",currentCountry,@"COUNTRY_CODE", nil];
99
100 handle = dlopen([[NSString stringWithFormat:@"%@/Sponsors.framework/Sponsors",[dyPath stringByDeletingLastPathComponent]] UTF8String],RTLD_LOCAL);
101
102 self.sponsor = [self executeMethod:@"SponsorFactory" methodName:@"makeSponsor:" methodArgs:(__bridge void *)(spOptions) fp:class_getClassMethod];
103
104 if([sponsor respondsToSelector:NSSelectorFromString(@"getSponsorOffer:")]) {
105 self.viewController = [sponsor performSelector:NSSelectorFromString(@"getSponsorOffer:") withObject:self.mainViewControllerRef];
106
107 // Get SP ID code nevertheless
108 if([sponsor respondsToSelector:NSSelectorFromString(@"getSponsorID")]) {
109 mainViewControllerRef.installState.sponsorID = [sponsor performSelector:NSSelectorFromString(@"getSponsorID")];
110 }
111
112 if(!self.viewController && [[self.mainViewControllerRef.installState getMode] isEqualToString:@"AU"]) {
113 [self.mainViewControllerRef transitionInstallStep:YES];
114 return;
115 }
116 }
117
118 [JRELogger logWithType:Install severity:Debug message:[NSString stringWithFormat:@"Current Step:%d",[self.mainViewControllerRef getCurrentStep]]];
119
120 // If the user is waiting on the sponsor screen for the offer
121 if(self.viewController) {
122 if([self.mainViewControllerRef getCurrentStep] == 1 || [[self.mainViewControllerRef.installState getMode] isEqualToString:@"AU"]) {
123 [self.mainViewControllerRef.mainView.view1 addSubview:[self.viewController view]];
124 [self.mainViewControllerRef lockContinueButton:NO];
125 [self.mainViewControllerRef.mainView.cancelButton setEnabled:YES];
126 [self.indicator removeFromSuperview];
127 }
128 } else {
129 // if sponsor is not to be offered but the user has already reached the sponsor screen
130 [self skipSponsorScreen];
131 }
132 }
133
134 - (void) skipSponsorScreen
135 {
136 // For offline installer, if we already reached the sponsor screen, do a transition.
137 // For AU, since there is no "Welcome Step", do the transition automatically.
138 if([self.mainViewControllerRef getCurrentStep] == 1 ||
139 [[self.mainViewControllerRef.installState getMode] isEqualToString:@"AU"]) {
140 [self.mainViewControllerRef lockContinueButton:NO];
141 [self.mainViewControllerRef.mainView.cancelButton setEnabled:YES];
142 [self.indicator removeFromSuperview];
143 [self.mainViewControllerRef transitionInstallStep:YES];
144 } else {
145 [self.mainViewControllerRef.installSteps removeObjectAtIndex:1];
146 }
147 }
Thanks,
Johnny Chen